了解Date.prototype.toISOString()ISO 8601格式吗? [英] Understanding Date.prototype.toISOString() ISO 8601 format?
本文介绍了了解Date.prototype.toISOString()ISO 8601格式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从
toISOString()方法返回简化的扩展ISO格式(ISO 8601)的字符串,该字符串始终为24或27个字符(YYYY-MM-DDTHH:mm:ss.sssZ或±YYYYYY-MM-DDTHH:mm:ss.sssZ .
- 什么时候返回第二种格式
±YYYYYY-MM-DDTHH:mm:ss.sssZ
? - 在
±YYYYYY-MM-DDTHH:mm:ss.sssZ
开头的±YY
是什么?
- When will the second format
±YYYYYY-MM-DDTHH:mm:ss.sssZ
be returned? - What means the
±YY
in the beginning of±YYYYYY-MM-DDTHH:mm:ss.sssZ
?
推荐答案
为规范说,它将在公元1年之前返回:
As the spec says, it will be returned when the year is before 1 AD:
const d = new Date()
// Thu Feb 25 2021 14:49:43 GMT+0200 (Eastern European Standard Time)
d.setFullYear(-7731)
// -306129149405605
console.log(d.toISOString())
// "-007731-02-25T13:09:54.395Z"
或适当的将来.
const d = new Date();
d.setFullYear(11931)
// 314343550183395
console.log(d.toISOString())
// "+011931-02-25T12:49:43.395Z"
这篇关于了解Date.prototype.toISOString()ISO 8601格式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文