moment.js 对时间变量进行管理

安装:

bower install moment --save # bower
npm install moment --save   # npm
Install-Package Moment.js   # NuGet
spm install moment --save   # spm
meteor add momentjs:moment  # meteor
相关函数:

moment().format('MMMM Do YYYY, h:mm:ss a'); // March 13th 2017, 5:54:37 pm
moment().format('dddd');                    // Monday
moment().format("MMM Do YY");               // Mar 13th 17
moment().format('YYYY [escaped] YYYY');     // 2017 escaped 2017
moment().format();                          // 2017-03-13T17:54:37+08:00
moment().format('MMMM Do YYYY, h:mm:ss a'); // March 13th 2017, 5:54:37 pm
moment().format('dddd');                    // Monday
moment().format("MMM Do YY");               // Mar 13th 17
moment().format('YYYY [escaped] YYYY');     // 2017 escaped 2017
moment().format();                          // 2017-03-13T17:54:37+08:00
moment().subtract(10, 'days').calendar(); // 03/03/2017
moment().subtract(6, 'days').calendar();  // Last Tuesday at 5:55 PM
moment().subtract(3, 'days').calendar();  // Last Friday at 5:55 PM
moment().subtract(1, 'days').calendar();  // Yesterday at 5:55 PM
moment().calendar();                      // Today at 5:55 PM
moment().add(1, 'days').calendar();       // Tomorrow at 5:55 PM
moment().add(3, 'days').calendar();       // Thursday at 5:55 PM
moment().add(10, 'days').calendar();      // 03/23/201
moment.locale();         // en
moment().format('LT');   // 5:58 PM
moment().format('LTS');  // 5:58:11 PM
moment().format('L');    // 03/13/2017
moment().format('l');    // 3/13/2017
moment().format('LL');   // March 13, 2017
moment().format('ll');   // Mar 13, 2017
moment().format('LLL');  // March 13, 2017 5:58 PM
moment().format('lll');  // Mar 13, 2017 5:58 PM
moment().format('LLLL'); // Monday, March 13, 2017 5:58 PM
moment().format('llll'); // Mon, Mar 13, 2017 5:58 PM



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值