因此,我只需要显示星期几,在使用 reg ex 之前,我正在寻找 moment.js 中的内置格式方法。
我得到的:
moment().add(2, 'days').calendar() = "Thursday at 12:46 PM"
我需要的是只得到“星期四”
最佳答案
与其使用 calendar
,不如使用 format
:
moment().add(2, 'days').format('dddd') // "Thursday"
API 文档解释说 calendar
给出了 the date compared to a reference date ,而 format
允许您 format the date how you like .
关于javascript - 有没有办法删除 hh :mm from moment. js, moment().add(2, 'days' ).calendar()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39849141/