【发布时间】:2019-02-06 06:17:30
【问题描述】:
我正在使用矩库将日期转换为 utc 格式。这是我的日期字符串:
var dateString = "2019-01-31T11:33:16.952+0000";
new Date("2019-01-31T11:33:16.952+0000") // o/p: Thu Jan 31 2019 03:33:16 GMT-0800 (Pacific Standard Time)
由于该日期距今天不到一周,因此我试图显示“n 天前”而不是实际日期的文本。但由于某种原因,当我执行此操作时,未来日期会显示为“6 天前”:
moment.utc("2019-01-31T11:33:16.952+0000").local().fromNow() // shouldnt this display "5 days ago"??
不知道为什么时刻没有正确转换日期,有什么想法可能是错误的吗?
【问题讨论】:
标签: javascript momentjs