helper-dateformat
Version:
Template helper for adding formatted dates using node-dateformat. Works with Handlebars, Lo-Dash, underscore, or any template engine that supports helper functions. Also compatible with verb, assemble and Template.
17 lines (13 loc) • 341 B
JavaScript
;
var dateformat = require('dateformat');
var typeOf = require('kind-of');
module.exports = function(date, format) {
if (typeOf(date) !== 'date') {
format = date;
date = new Date();
}
if (typeof format !== 'string' || format === 'today') {
format = 'mmmm dd, yyyy';
}
return dateformat(date, format);
};