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
Description: A 5.5kb javascript date library for parsing, validating, manipulating, and formatting dates.
Written by James Van Dyke
Related protips
2 Responses
Is it possible to get current date using today relative keyword? Something like:
var date = moment('today');
???
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/
Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside