Formatting Dates in AngularJS

Here’s a cheeky little trick for you – if you have a date property that you want to format in your view, you can use this simple bit of AngularJS markup to do just that:

{{MyObject.MyDate | date:"dd/MM/yyyy HH:mm"}}

This takes a pretty nasty-looking Json style date which looks like this:


and turns it into a beautifully crafted date which looks like this:

04/02/2015 13:30

You’re welcome!

Tagged with: ,