关于Angular中时间戳的计算

前言

使用的是Moment.js 插件,网址(https://momentjs.com/)

正文

步骤一:引用import * as moment from 'moment';

步骤二:

1.(TOMO):获取十天前的时间

moment().subtract(10, 'days').toDate();   // 06/30 2018
moment().subtract(10, 'days').calendar();  // 06/30 2018
 
 
2.(TOMO): 时间的格式转换
 
moment().format('LLL');  // July 9, 2018 11:03 PM
moment().format('MMMM Do YYYY, h:mm:ss a');  // July 9th 2018, 11:05:39 pm
 
后记
如有想使用moment.js 插件,具体的使用方法还请参考官方文档,希望对你有帮助。网址:(https://momentjs.com/)
 

猜你喜欢

转载自www.cnblogs.com/OneManStep/p/9286646.html