> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# Format time using moment.js in meteor
- URL: https://til.codes/format-time-using-moment-js-in-meteor/
- Published: 2016-01-07T17:18:06.000Z
- Updated: 2016-01-07T17:18:06.000Z
- Author: Manu Ajith
- Tags: meteor, meteor.js, moment.js, moment, #Import 2024-07-13 21:01

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.