Reputation: 1009
I get a date in this format:
2015-02-19 00:00:00
Now I need to format this date to
19-02-2015
I tried:
sc.documents.datestring = $filter("date")('2015-02-19 00:00:00', 'dd-MM-yyyy');
But that didn't work, anyone have an idea of how to do this?
Upvotes: 1
Views: 30
Reputation: 112
yes when ever you want to display date using some format using angular filter we need to use
$filter('date').(date, format, timezone);
format ,like as above only... https://docs.angularjs.org/api/ng/filter/date
Upvotes: 0
Reputation: 863
First argument should be Date object, not a string. All yon need to do is:
sc.documents.datestring = $filter("date")(new Date('2015-02-19 00:00:00'), 'dd-MM-yyyy');
Upvotes: 2