Now1.0.0+
moment();
moment(undefined);
// From 2.14.0 onward, also supported
moment([]);
moment({});
To get the current date and time, just call moment()
with no parameters.
var now = moment();
This is essentially the same as calling moment(new Date())
.
Note: From version 2.14.0, moment([])
and moment({})
also returnnow. They used to default to start-of-today before 2.14.0, but that wasarbitrary so it was changed.
Note: Function parameters default to undefined
when not passed in. Moment treats moment(undefined)
as moment()
.
var x = undefined;
moment(x).isSame(moment(), 'second'); // true
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .