[Version 2] Format Dates in HTML Templates

When you're adding a custom date field to your donation form, profile, or user accounts, you might want to theme and display these in different ways.

Themes with version 2.4.0 and upwards use angular-moment to bring in the moment.js library. Angular-Moment provides us with a parsing filter and display filters. It also has some nice things around time-from and duration filters that we use across the site to help us parse dates.

If you have a custom date field on your profile page, for example, we can use these filters to both parse the field into a Javascript Date, then render the field:

 #{{profile.public.my_date |  amParse:"MM/DD/YYYY" | amDateFormat:"MMMM YYYY" }} 

The moment.js library has several display format options to help you parse and render dates. The Angular-Moment library also has several handy directives to help you display relative dates, durations and more.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us