更新时间:2023-01-31 14:40:49
您正在记录矩对象。正如内部属性指南所述:
You are logging a moment object. As the Internal Properties guide states:
要打印出Moment的值,请使用
.format()
,.toString()
或.toISOString()
。
let createdDate = moment(new Date()).utc().format();
let expirationDate = moment(createdDate).add(1, 'd');
console.log(expirationDate.format());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
请注意,您可以使用 moment()
(无需使用 new Date()
)或 moment.utc()
。
Please note that you can get the current date using moment()
(no need to use new Date()
) or moment.utc()
.