0

Im trying to set the format of a date as 'dd/MM/yyyy' using angular's $filter in this way:

var toDate;
$scope.endDate = {
        value: new Date(2013, 9, 22)
};

$scope.$watch('metric.value', function (newValue, oldValue) {
        toDate = $filter('date')($scope.endDate,'dd/MM/yyyy');
        console.log(toDate);
}

And the output of the console shows the following:

Object {value: Tue Oct 22 2013 00:00:00 GMT+0200 (Romance Daylight Time)}

How can I actually change it to the format dd/MM/yyyy and parse it to a String?

1
  • 1
    toDate = $filter('date')($scope.endDate.value, 'dd/MM/yyyy'); Commented Feb 17, 2016 at 14:47

1 Answer 1

2

I think you error when typing.

Maybe you need filter correct code below: toDate = $filter('date')($scope.endDate.value,'dd/MM/yyyy');

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

1 Comment

Totally correct. Second time that I have the same mistake... Thanks!

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.