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。
当前回答
formatCalendarDate = function (dateTime) {
return moment.utc(dateTime).format('LL')
}
其他回答
你也可以使用这种格式:
时刻()。格式(“ddd、ll ');// 2017年1月4日,星期三
使用格式(“我”)
取决于你想用它做什么,格式('LL')可以做到这一点。它会产生这样的东西:
Moment().format('LL'); // => April 29, 2016
试试这个:
moment.format().split("T")[0]
moment(date).format(DateFormat)
这里的DateFormat应该是DateFormat = 'YYYY-MM-DD'
每当我使用moment.js库时,我以这种方式指定所需的格式:
moment(<your Date goes here>).format("DD-MMM-YYYY")
or
moment(<your Date goes here>).format("DD/MMM/YYYY")
... 我希望你能明白
在format函数中,放入所需的格式。上面的例子将去掉日期中所有不需要的元素,如分钟和秒