2

In my controller, I receive a JSON object that has a date field:

vm.data.AcknowledgedByDate = "07/01/2016 15:02"

When I apply the date format filter:

{{vm.data.AcknowledgedByDate | date:'dd-MMM-yyyy'}}

it doesn't do anything. Why?

1 Answer 1

6

Because its a string, convert it into a date object before passing it to filter.

$scope.date = new Date("07/01/2016 15:02");

Below is a fiddle on the same. https://jsfiddle.net/nho955qx/1/

Sign up to request clarification or add additional context in comments.

1 Comment

It can also be a timestamp integer. Bare in mind the source of the value though as javascript (and angular's date filter) expect it to be in milliseconds, while it is common for other languages to provide it in seconds.

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.