1

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?

2 Answers 2

2

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');
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.