Moment.js | Parse, validate, manipulate, and display dates in javascript.

Moment.js | Parse, validate, manipulate, and display dates in javascript..

https://raw.github.com/timrwood/moment/1.7.2/moment.js

moment().format('MMMM Do YYYY, h:mm:ss a');
moment().format('dddd');
moment().format("MMM Do YY");
moment().format('YYYY [escaped] YYYY');
moment().format();
November 24th 2012, 8:53:44 pm
Saturday
Nov 24th 12
2012 escaped 2012

 

Timeago

moment("20111031", "YYYYMMDD").fromNow();
moment("20120620", "YYYYMMDD").fromNow();
moment().startOf('day').fromNow();
moment().endOf('day').fromNow();
moment().startOf('hour').fromNow();
a year ago
5 months ago
21 hours ago
in 3 hours
an hour ago

Calendar Time

moment().subtract('days', 10).calendar();
moment().subtract('days', 6).calendar();
moment().subtract('days', 3).calendar();
moment().subtract('days', 1).calendar();
moment().calendar();
moment().add('days', 1).calendar();
moment().add('days', 3).calendar();
moment().add('days', 10).calendar();
11/14/2012
last Sunday at 8:54 PM
last Wednesday at 8:54 PM
Yesterday at 8:54 PM
Today at 8:54 PM
Tomorrow at 8:54 PM
Tuesday at 8:54 PM
12/04/2012

Internationalization

moment().format('L');
moment().format('LL');
moment().format('LLL');
moment().format('LLLL');
11/24/2012
November 24 2012
November 24 2012 8:54 PM
Saturday, November 24 2012 8:54 PM
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s