I'm thinking of strings like "one minute ago" or "3 weeks ago", that kind of thing.
I could easily port examples I've found in other languages but there's no need to reinvent the wheel if this stuff is already out there.
I wrote a library called moment that does what DateJS does, only it's smaller, doesn't modify Date.prototype
, and works in both the browser and NodeJS.
npm install moment
Usage:
moment(1316369911638).fromNow() // "3 minutes ago"
It supports i18n and customization as well, all strings are exposed for modification.
Something you can try is date.js: http://www.datejs.com/
To make it node compatible at the very bottom of the script add the line:
module.exports = Date;
Then you can require it:
var date = require('./date');
Assuming date.js is in the same folder, otherwise modify the require path.
Then a simple code sample to test is:
console.log( date.today().next().thursday() )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With