【发布时间】:2013-01-06 10:41:30
【问题描述】:
我注意到,当我使用 momentJs 在我的时区以特定格式输出日期时,会丢失一天。
我在 UTC-4:30 时区。
这并非在所有时区都会发生;注意到这在 UTC-5:00 时区可以正常工作。
以下是console.log连续运行的结果:
正确的输出:
moment([2013, 0, 24])
瞬间
_a: 数组[8]
_d:2013 年 1 月 24 日星期四 00:00:00 GMT-0430(委内瑞拉标准时间)
_isUTC:假
_lang: 假
_proto:对象
moment([2013, 0, 24]).toDate()
2013 年 1 月 24 日星期四 00:00:00 GMT-0430(委内瑞拉标准时间)
输出不正确:
moment('01/24/2013').format('MM/DD/YYYY')
“2013 年 1 月 23 日”
moment([2013, 0, 24]).format('MM/DD/YYYY')
“2013 年 1 月 23 日”
请注意,一旦使用了 .format() 方法,就会丢失一天,并输出 23 号而不是 24 号。
谁能解释这种行为?同样,它似乎特定于时区。
【问题讨论】:
标签: javascript jquery momentjs