Moment.js 2.11.2 - Parse, validate, manipulate, and display dates in JavaScript.

by February 16, 2016 0 comments

Format Dates

moment().format('MMMM Do YYYY, h:mm:ss a'); // February 16th 2016, 4:44:02 pm
moment().format('dddd');                    // Tuesday
moment().format("MMM Do YY");               // Feb 16th 16
moment().format('YYYY [escaped] YYYY');     // 2016 escaped 2016
moment().format();                          // 2016-02-16T16:44:02+07:00

Relative Time

moment().subtract(10, 'days').calendar(); // 02/06/2016
moment().subtract(6, 'days').calendar();  // Last Wednesday at 4:48 PM
moment().subtract(3, 'days').calendar();  // Last Saturday at 4:48 PM
moment().subtract(1, 'days').calendar();  // Yesterday at 4:48 PM
moment().calendar();                      // Today at 4:48 PM
moment().add(1, 'days').calendar();       // Tomorrow at 4:48 PM
moment().add(3, 'days').calendar();       // Friday at 4:48 PM
moment().add(10, 'days').calendar();      // 02/26/2016

Multiple Locale Support

moment.locale();         // en
moment().format('LT');   // 4:48 PM
moment().format('LTS');  // 4:48:31 PM
moment().format('L');    // 02/16/2016
moment().format('l');    // 2/16/2016
moment().format('LL');   // February 16, 2016
moment().format('ll');   // Feb 16, 2016
moment().format('LLL');  // February 16, 2016 4:48 PM
moment().format('lll');  // Feb 16, 2016 4:48 PM
moment().format('LLLL'); // Tuesday, February 16, 2016 4:48 PM
moment().format('llll'); // Tue, Feb 16, 2016 4:48 PM

Homepage : http://momentjs.com/
Link Download: http://momentjs.com/downloads/moment.js

An Nguyen

Developer

Sharing daily exciting lesson learned and posts about .NET, SQL Server, HTML, Javascript - jQuery, CSS - Bootstrap, SalesForce CRM, Kentico CMS and so on.

0 comments :

Post a Comment