/ Date (1445301615000-0700) /
It means UTC time 2015-10-19 17:40:15
Sorry, this is wrong. UTC time 2015-10-20 00:45:15 . Your value corresponds to local time in the time zone with an offset of -07:00 at that moment.
In this wine format, part of the timestamp is still based solely on UTC. Offset is additional information. It does not change the timestamp. You can give another bias or completely lower it, and this is all the same point in time.
All of the following are equivalent with respect to a point in time.
/Date(1445301615000-0700)/ /Date(1445301615000)/ 2015-10-20T00:40:15Z 2015-10-19T17:40:15-07:00
Please note that in the ISO format, the offset changes the value, but in the MS format this is not so.
It would be better if you did not use this format, since ISO8601 is a much more reasonable choice for JSON. However, if you are stuck with it, it is best not to deserialize it to a DateTime . Use DateTimeOffset instead.
Consider:
string s = "\"/Date(1445301615000-0700)/\""; DateTime dt = JsonConvert.DeserializeObject<DateTime>(s); Console.WriteLine(dt.Kind);
This is not good. basically, if there is any bias, he thinks it is your local time zone as it may be, but it may not be so.
string s = "\"/Date(1445301615000)/\""; DateTime dt = JsonConvert.DeserializeObject<DateTime>(s); Console.WriteLine(dt.Kind);
This is normal, but you have lost control of this local time.
string s = "\"/Date(1445301615000-0700)/\""; DateTimeOffset dto = JsonConvert.DeserializeObject<DateTimeOffset>(s); Console.WriteLine(dto);
This is much better. And if you really want a UTC DateTime , then:
string s = "\"/Date(1445301615000-0700)/\""; DateTimeOffset dto = JsonConvert.DeserializeObject<DateTimeOffset>(s); DateTime utc = dto.UtcDateTime; Console.WriteLine(utc);
So, the main lesson, regardless of format, if the data contains information about the time zone offset, then deserialize to DateTimeOffset . Although using DateTime may work in some cases, you are asking .NET to interpret the offset and apply default behavior, which is often not desirable.