简体   繁体   中英

What's the different betweet moment().utc().toISOString() and moment().utc().format()

I'm using moment js library and I'm a bit confused by the result I'm getting about the timezone.

moment().utc().toISOString();
"2016-02-08T23:31:45.317Z"

moment().utc().format();
"2016-02-08T23:32:42+00:00"

What I don't understand is what is 317Z ? and What's the difference between toISOString and format And are they the same?

"2016-02-08T23:31:45.317Z" refer to the CCYY-MM-DDTHH:MM:SS.sss time format. 317 is the time in fractions of second while the Z means "Zulu time" (UTC).

In ISO 8601 there are multiple time formats, eg

hh:mm:ss.sss
hh:mm:ss

And there are multiple ways to specify the time zone , eg

  • Z means UTC time.

  • +00:00 means an offset of zero from UTC. So UTC too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM