Thanks erundook.
I was actually trying to format the ISO date that Meteor/mongodb stored, not convert a Javascript date object into
I guess the question is whether Meteor should just be bundling vanilla Handlebars or whether it should include helpers to make Handlebars more usable (being able to format a date for display on the web client seems to be one of those things that really should be included to make people's lives easier :-)
Anyways, what I did was add this to a file in the client subfolder (it can also be added to the isClient part of the toplevel app if you want to put everything into a single giant JS file like the examples):
// format an ISO date using Moment.js
//
http://momentjs.com/ // moment syntax example: moment(Date("2011-07-18T15:50:52")).format("MMMM YYYY")
// usage: {{dateFormat creation_date format="MMMM YYYY"}}
Handlebars.registerHelper('dateFormat', function(context, block) {
if (window.moment) {
var f = block.hash.format || "MMM DD, YYYY hh:mm:ss A";
return moment(context).format(f); //had to remove Date(context)
}else{
return context; // moment plugin not available. return data as is.
};
});
Then for display of my collection HTML, I used this in the template:
{{dateFormat gallerymodified format="MMM d YYYY"}}
ken