Last Updated: February 25, 2016
·
2.351K
· jamesvandyke

Use moment.js to handle dates and times in JavaScript

Need to do mathy stuff on time? Convert time zines, parse, add, subtract, convert to fuzzy time (e.g., a moment ago, an hour ago)? Need it to work on your Arabic language site too?

Just use moment.js

http://momentjs.com/

Description: A 5.5kb javascript date library for parsing, validating, manipulating, and formatting dates.

2 Responses
Add your response

Is it possible to get current date using today relative keyword? Something like:
var date = moment('today');

???

over 1 year ago ·

Not using a keyword, but you can by simply calling the moment() function itself, like so:

var now = moment()

For the details about parsing, see http://momentjs.com/docs/#/parsing/now/

over 1 year ago ·