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

Solution 1:

They're for different purposes.

  • UTC is the primary time standard by which the world regulates clocks and time.
  • ISO is standard format 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.

Solution 2:

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()