0

In AngularJS, I am using location.search() to get date field from URL passed through in param myDates as below

$scope.myDates= $location.search()['myDates'];

However, it works only if it is in the format MMMM-DD-YYYY

I need it to be in the format DD-MMMM-YYYY as in 20-12-2010 etc.

How to do that?

1 Answer 1

1

If you want to treat date as date, the first thing would be to convert the querystring date into a Date data type using

$scope.myDates=Date.parse($location.search()['myDates']);

As this MDN documentation says about this method, the input format of string should be

A string representing an RFC2822 or ISO 8601 date.

Once you have converted it into date you can do any manipulation and formatting using Date object toString() method or $date filter in AnuglarJS

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

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.