Regardless of many posts, I read the magic in my code. I have a DateTime value in db ('2011-03-30 00: 00: 00.000') that I am retrieving for an asp.net/mvc page where some javascript needs to be read and compared. The magic is as follows:
<% DateTime unixTimeOffset = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime testDate = new DateTime(2011,03,30,0,0,0,0); %> <%= (testDate - unixTimeOffset).TotalMilliseconds %> ...
The last line of code gives me this value: 1301443200000 When I try to read it in JavaScript, I have:
val myDate = new Date(1301443200000);
And myDate tue March 29, 2011 20:00:00 GMT-0400 (Eastern Daylight Time) {} But it should not be March 30, as it should be.
I understand that it provides a date that refers to local time, GMT-4, but what is the solution to gain independence? Any ideas? Thank you
Maxim source share