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:

2015-02-04T13:30:10Z

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

04/02/2015 13:30

You’re welcome!

Posted in AngularJS, Code Tagged with: ,

About Maff

Maff Rigby

I'm a certified .Net, Umbraco and AngularJS freelance developer with over 15 years experience in the IT industry. As well as writing code I love to teach; I run a number of workshops and 1-1 coaching sessions on Angular JS and Umbraco, and share what I know and learn here!

I’m social (ish)

Connect with me on LinkedIn, follow me on Twitter, or fail to find me on Facebook.