local()


moment().local();

在原始的 moment 上设置标记,以使用本地时间(而不是原始的 moment 时间)显示 moment。

var a = moment.utc([2011, 0, 1, 8]);
a.hours(); // 8 UTC
a.local();
a.hours(); // 0 PST

也可以用于转换出固定的偏移模式:

moment.parseZone('2016-05-03T22:15:01+02:00').local().format(); // "2016-05-03T15:15:01-05:00"

有关 UTC 模式的更多信息,参阅 moment.utc()

moment().local();

Sets a flag on the original moment to use local time to display a moment instead of the original moment's time.

var a = moment.utc([2011, 0, 1, 8]);
a.hours(); // 8 UTC
a.local();
a.hours(); // 0 PST

Local can also be used to convert out of a fixed offset mode:

moment.parseZone('2016-05-03T22:15:01+02:00').local().format(); // "2016-05-03T15:15:01-05:00"

See moment.utc() for more information on UTC mode.