user3842029 user3842029 - 1 year ago 103
AngularJS Question

Convert date from one format to another - AngularJS

How do I convert date from mm-dd-yyyy to mm/dd/yyyy in AngularJS. Here is the plunker

$ = '07-28-2016';

{{ data | date:'filter'}} //should return 07/28/2016

Answer Source

First, start with an actual Date instance

$ = new Date('2016-07-28'); // ISO 8601 date formats are less ambiguous

then use the date filter, ie

{{ date | date: 'MM/dd/yyyy' }}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download