I have an asp.net mvc calendar application (using jquery ui datepicker) and i am running into a weird situation where when i test on a US webserver i see a certain date and when i test on a London web server i see a different date (the date before)
Here are the details:
I am storing a date in sql server as:
2010-09-16 00:00:00.000
I am then loading that into C# DateTime object.
I need to pass that down as part of a json object to my clientside javascript so i was suggested this solution:
jsonobject.Date = UnixTicks(a.Date),
where UnixTicks is:
private static double UnixTicks(DateTime dt)
{
DateTime d1 = new DateTime(1970, 1, 1);
DateTime d2 = dt.ToUniversalTime();
TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
return ts.TotalMilliseconds;
}
I am then converting it to a javascript date by using this code below on the client side:
var d = new Date(jsonobject.Date);
does anyone know why given a US server or a London server i would get back a different date. At first, i thought it was the
DateTime d2 = dt.ToUniversalTime();
but i changed that to:
DateTime d2 = dt;
and still saw the same issue. (on London web server date would show up 1 day prior to the US web server)
any suggestions?