Asp.Net MVC 2 Futures doesn’t seem to handle JSON DateTime well (including double and decimal values). As such, I setup all inputs as string, used Data Validation, and things worked pretty well.
However, I have this JSON2.js date from Firefox 3.6:
"/Date(1288296203190)/"
How do I turn this in to a valid date in C#?
var a = new DateTime(1288296203190);
That doesn’t give the right date (1/2/0001 11:47:09 AM) instead of Thu Oct 28 2010 16:03:23 GMT-0400 (Eastern Daylight Time). It’s probably because a 32 bit integer is only 10 digits. However, this fails too:
var a = Int64.Parse("1288296203190");
var b = new DateTime(a);
b’s value is 1/2/0001 11:47:09 AM.
What did it do? Wrap? Is this some kind of time travel “signed bit” issue?
The issue is the difference in epoch. Looks like the JSON2.js date you have uses the unix epoch (January 1, 1970) measured in ms. From the System.DateTime(long ticks) documenttion:
Something like this should get you what you want.