A date formatter and parser for node
A small library that provides a few very useful methods for displaying dates, including a formatter and a parser.
$ npm install dateable
var dateable = require'dateable';var date = 2009 4 23;var str = dateabledate 'MM/DD-YYYY, hh:mm';// => 05/23-2012, 22:10
Parse a formatted date and return the original Date object
dateableparsestr 'MM/DD-YYYY, hh:mm';// => Sat May 23 2009 00:00:00 GMT+0000 (CEST)
If you want to include text in the formatting, you need to escape it with either ' or ".
var format = '"I went to the moon a" dddd "in" MMMM, YYYY';dateabledate format;// => I went to the moon a Saturday in May, 2009
You can also get the relative date, and the difference between dates.
dateablewhen2008 4 20;// => 4 years agodateablewhen2020 4 30;// => in 8 yearsdateablediff2015 ;// => 3 years
Return formatted date
Return original date from format
Returns relative date
Returns the difference between the two dates
Based on ISO 8601 with some additions. See tests for examples.