Unix Timestamp (seconds)1.6.0+
moment.unix(Number)
To create a moment from a Unix timestamp (seconds since the Unix Epoch), use moment.unix(Number)
.
var day = moment.unix(1318781876);
This is implemented as moment(timestamp * 1000)
, so partial seconds in the input timestamp are included.
var day = moment.unix(1318781876.721);
Note: Despite Unix timestamps being UTC-based, this function creates a moment object in local mode. If you need UTC, then subsequently call .utc()
, as in:
var day = moment.unix(1318781876).utc();
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .