1.日期格式化
moment().format('MMMM Do YYYY, h:mm:ss a'); // 八月 2日 2019, 2:15:46 下午
moment().format('dddd'); // 星期五
moment().format("MMM Do YY"); // 8月 2日 19
moment().format('YYYY [escaped] YYYY'); // 2019 escaped 2019
moment().format(); // 2019-08-02T14:15:46+08:00
2.相对时间
moment().format('MMMM Do YYYY, h:mm:ss a'); // 八月 2日 2019, 2:15:46 下午
moment().format('dddd'); // 星期五
moment().format("MMM Do YY"); // 8月 2日 19
moment().format('YYYY [escaped] YYYY'); // 2019 escaped 2019
moment().format(); // 2019-08-02T14:15:46+08:00
3.日历时间
moment().subtract(10, 'days').calendar(); // 2019年7月23日
moment().subtract(6, 'days').calendar(); // 上周六下午2点17
moment().subtract(3, 'days').calendar(); // 本周二下午2点17
moment().subtract(1, 'days').calendar(); // 昨天下午2点17分
moment().calendar(); // 今天下午2点17分
moment().add(1, 'days').calendar(); // 明天下午2点17分
moment().add(3, 'days').calendar(); // 下周一下午2点17
moment().add(10, 'days').calendar(); // 2019年8月12日