问题描述:

I pick some date and time in javascript and then want to store it on server (.NET). Dates are supposed to be in future from the current moment (so they won't be before 1970).

Having read topics here on SO I learnt it's better to store date as a string and people suggest using Date.prototype.toISOString() or Date.prototype.toUTCString().

I've read that toISOString() is not available in IE 7. And I'd like to know other differences, when I should choose one or another function.

Thank you!

网友答案:

Both are different. ISO is standard format time. UTC is the primary time standard by which the world regulates clocks and time. ISO also supports ms in it format.

So if you want to send data to the server, better send the ISO, because ISO is the standard format:

var date = new Date();
sendDate(date.toISOString());

You can also use toISOString in IE7 polyfill.

网友答案:

I hope it will helpful to you.

Summary About toISOString() :-

The toISOString() method returns a string in ISO format (ISO 8601 Extended Format), which can be described as follows: YYYY-MM-DDTHH:mm:ss.sssZ. The timezone is always UTC as denoted by the suffix "Z".

Refer Below link for more information about toISOString().

Date.prototype.toISOString()

Summary About toUTCString() :-

The toUTCString() method converts a date to a string, using the UTC time zone.

Refer Below link for more information about toUTCString()

Date.prototype.toUTCString()

相关阅读:
Top