将 Date 对象转换为 moment 对象

要将 Javascript Date 对象转换为片刻(片刻对象),只需调用 moment 并将 Date 作为参数传递

moment(new Date());
// Moment {_isAMomentObject: true, _i: Sun Jul 31 2016 11:08:02 GMT+0300 (Jerusalem Daylight Time), _isUTC: false, _pf: Object, _locale: Locale…}

要将时刻转回 Javascript 日期,请使用 .toDate() 方法

var now = new Date();
var mom = moment(now)
//undefined
mom
// Moment {_isAMomentObject: true, _i: Sun Jul 31 2016 11:10:32 GMT+0300 (Jerusalem Daylight Time), _isUTC: false, _pf: Object, _locale: Locale…}
mom.toDate()
// Sun Jul 31 2016 11:10:32 GMT+0300 (Jerusalem Daylight Time)