What's the difference between datetime in ISO 8601 and UTC formats in javascript?

前端 未结 3 700
终归单人心
终归单人心 2021-01-31 03:02

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). H

3条回答
  •  日久生厌
    2021-01-31 03:15

    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 its format.

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

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

    You can also use toISOString in IE7 polyfill.

提交回复
热议问题