Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx" rel="nofollow noreferrer">this msdn link</a>, <code>DateTime</code> objects are...</p> <blockquote> <p>...represented in JSON as "/Date(number of ticks)/". The number of ticks is a positive or negative long value that indicates the number of ticks (milliseconds) that have elapsed since midnight 01 January, 1970 UTC.</p> </blockquote> <p>So you are correct that .NET assumes, but it's UTC instead of GMT (though <a href="http://geography.about.com/od/timeandtimezones/a/gmtutc.htm" rel="nofollow noreferrer">they are similar</a>). There are <a href="https://stackoverflow.com/questions/726334/asp-mvc-jsonresult-date-format/726869#726869">some</a> <a href="https://stackoverflow.com/questions/1341719/custom-javascriptconverter-for-datetime/1347448#1347448">good</a> <a href="https://stackoverflow.com/questions/1224793/javascript-serialization-of-datetime-in-asp-net-is-not-giving-a-javascript-date-o/1227767#1227767">answers</a> here on SO that give more details and also provide methods for parsing the JSON into a usable date on the client.</p> <p>As far as converting dates from UTC to a specific time zone, on the server you could use the <a href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx" rel="nofollow noreferrer"><code>TimeZoneInfo</code></a> class which has a <a href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.converttimefromutc.aspx" rel="nofollow noreferrer"><code>ConvertTimeFromUtc</code></a> method. Or you could write a custom converter that inherits from the <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptconverter.aspx" rel="nofollow noreferrer"><code>JavaScriptConverter</code></a> class. In javascript, there are the <a href="http://www.w3schools.com/jsref/jsref_utc.asp" rel="nofollow noreferrer"><code>UTC</code></a> and <a href="http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp" rel="nofollow noreferrer"><code>getTimezoneOffset</code></a> methods that could be used.</p> <p>Hope this helps and good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload