What's the best way to pass a .NET System.DateTime using JSON so that javascript from the jQuery side can construct a javascript Date object?

I am building a JSON string "manually" on the server side.

Should I convert .ToString (System.DateTime.Milliseconds) on the server side and use javascript Date.setTime (milliseconds) on the client side?

+2


source to share


1 answer


Using milliseconds, I believe this is your best bet as it leads to a simple conversion. One issue that you want to be careful about is that clocks can be in different time zones, so you might need to be aware of this and perhaps send the time in a known standard time zone.

If you just need to display, you can send the date as a string, but that makes it difficult to navigate to change the time zone.



The best solution will depend on how it is used and your needs.

+3


source







All Articles