formatCalendarDate = function (dateTime) {
return moment.utc(dateTime).format('LLL');
};
它显示:“2013年2月28日09:24”
但是我想把最后的时间去掉。我该怎么做呢?
我用的是Moment.js。
formatCalendarDate = function (dateTime) {
return moment.utc(dateTime).format('LLL');
};
它显示:“2013年2月28日09:24”
但是我想把最后的时间去掉。我该怎么做呢?
我用的是Moment.js。
当前回答
尝试new Date().toDateString()
推荐-“2022年六月17日”
其他回答
formatCalendarDate = function (dateTime) {
return moment.utc(dateTime).format('LL')
}
moment(date).format(DateFormat)
这里的DateFormat应该是DateFormat = 'YYYY-MM-DD'
抱歉这么晚才插话,但如果你想删除moment()的时间部分,而不是格式化它,那么代码是:
.startOf('day')
裁判:http://momentjs.com/docs/ /操作/开始/
试试这个:
moment.format().split("T")[0]
您可以使用这个构造函数
moment({h:0, m:0, s:0, ms:0})
http://momentjs.com/docs/#/parsing/object/
console.log(时刻)。格式('YYYY-MM-DD HH:mm:ss')) Console.log (moment({h:0, m:0, s:0, ms:0})。格式('YYYY-MM-DD HH:mm:ss')) < script src = " https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js " > < /脚本>