AngularJS Convert JSON Date into any format

Using Javascript, we tend to want to change the JSON date given (example YYYY-MM-DD) by formatting the date and then present it to be the format that we want.


2017-05-21 which we would need to convert it to 21 May 2017


Using AngularJS, conversion of this is simple by using only a single line of code. Since we have no control over the JSON file output, the only way is to modify the output on the front end (web).

Effective Date: {{selectedOption.effDateFrom}}

Will yield 2017-05-21

Effective Date : {{selectedOption.effDateFrom | date : 'dd MMMM yyyy'}}

Will yield 21 May 2017

All done with just a change of line.
Thank you AngularJS. (Now to pick up Angular JS2 in the future)

One Response

  1. jm May 26, 2018

Leave a Reply