/ meteor

Format time using moment.js in meteor

If you want to format a time field from you database, say for e.g.: createdAt, the following helper can be used.

UI.registerHelper('formatTime', function(context, options) {
  if(context)
    return moment(context).format('MM/DD/YYYY');
});

An alternate way would be to write a helper for one particular view, but creating a global helper would help us to re-use the helper elsewhere too and keep the code DRY.

Manu S Ajith

Manu S Ajith

Tech Entrepreneur, dating Elixir, in long-term ❤️ w/ Ruby, had multiple one night stands w/ Go. Into functional paradigms DDD/CQRS/EventSourcing architecture these days. @manusajith on the interwebs

Read More