为什么会这样:
new Date("2019-01-10T00:00:00+0100")
返回
Thu Jan 10 2019 00:00:00 GMT+0100 (Central European Standard Time)
在我的笔记本电脑上使用 Firefox 和 Chrome 而不是
invalid date
在笔记本电脑上的 Safari 和 iOS 上的 Chrome 上?
最佳答案
因为网络浏览器不一致... :-(
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local.
根据记录,new Date("2019-01-10T00:00:00+01:00")
(在时区部分的小时和分钟之间有一个冒号)似乎在 Safari 上做正确的事。
关于javascript - 为什么这个日期在 iOS 和 Safari 上无效,但在 Chrome 和 Firefox 上无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54121362/