Format dates real fancy-like in the browser. Good for search engines and humans.
This was originally implemented on the npmjs.com website, then proved useful enough to extract into a standalone module.
Weighs in at 4K, minified and gzipped.
npm install browser-date-formatter --save
format data attributes on all HTML elements you want
(any textContent you put here will be replaced with "2016-04-07")
format data attribute is optional. If omitted, a human-friendly relative date
string like "5 minutes ago" is displayed. If specified, the format is expected
to be a strftime pattern, such as
When the DOM is ready, this module finds all elements with a
attribute and converts their text content to the given
formatter function is executed every 5 seconds to keep relative dates fresh.
If you're not using browserify in your project, you can use the wzrd.in hosted version instead:
npm installnpm test
Generated by package-json-to-readme