Filters in Meteor


I’m wondering about filters in Meteor.
In Angular you can use {{mytime | date}} to display a nice shorter date. And also for example {{money | currency}} to re-format your integer to $200.00 instead of 200.

So my question is, how do you do this in Meteor?

I’ve got

var time = new Date();

And i want to display it nicely. Perhaps just “20:33”


Use a helper.

E.g.: using moment to format a date:

  'formatDate': function(date) {
    return moment.utc(date).format("DD/MM/YYYY");

When displaying, just add the helper name first:

{formatDate myDate}}

That seems really confusing and i couldnt get it to work :frowning:

I’m currently displaying {{timeCreated}} in my html, in a template. Which returns “Thu Apr 09 2015 20:24:03 GMT+0200 (CEST)”

Is there no way like angular? {{timeCreated | date:“MM/DDD/YYYY”}}?

Just like I said, define a helper to format your date as you prefer. I recommend MomentJS for that.

So, in your html, just add the helper name before your variable. Supposing your helper is named “formatDate”, it’d be:

{{formatDate timeCreated}}

Oh. Your code works now when i installed momentjs ^^

meteor add momentjs:moment


Do you know how i can change it from “09:08:30 PM” to “21:08:30”? Cant find it on

Looks like if you use upper case hour tokens in your format HH it will use 24 hour time. Lower case hh is 12 hours time used with a for AM/PM: hh a

Awesome, thanks a lot!