我尝试按照moment.js初始指定eastern 8
时区。使用moment.js设置初始时区
我将我的os时区更改为western 4
,然后我输入如下的相同时间戳。
moment().utcOffset(-240);
moment(1473998400000).toDate();
moment().utcOffset(480);
moment(1473998400000).toDate();
// both output >>> Fri Sep 16 2016 00:00:00 GMT-0400 (EDT)
但我不明白,为什么我也得到不同的初始时区相同的输出?
我做错了什么:(
设置'utcOffset'只会改变'moment'对象的行为。它不会改变你正在谈论的时间,因此''toDate''不会产生,因为'Date'对象只能在当地时间使用。 –