安装:
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