2

In my project am getting a date like this "05/23/2016" format. But i want to show it in the view like this "23 May 2016" using Angular.

How to do it ? Please help...

2

4 Answers 4

1

Create a date object out of your string (in your controller, for example):

$scope.dateVar = new Date("05/23/2016");

and then use the date filter in your template:

{{ dateVar | date:'dd MMMM yyyy' }}
Sign up to request clarification or add additional context in comments.

Comments

1

First split the string "05/23/2016" on "/".

$scope.today = "05/23/2016";
$scope.date = $scope.today.split("/");

Then convert your string date into Date object

$scope.actualdate = new Date($scope.date[2],$scope.date[0] - 1,$scope.date[1]);

Now you can use any combination of the date filter from AngularJS docs

{{actualdate | date: 'dd MMMM yyyy'}} // 23 May 2016
{{actualdate | date: 'yyyy dd MMMM'}} // 2016 23 May
{{actualdate | date: 'dd MMMM'}} // 23 May

You can use any combination and format the date as you want.

EXAMPLE FIDDLE

Comments

0

If You want to use angularjs to change the format , use $filter

$filter('date')(date, format, timezone)

refer to this link https://docs.angularjs.org/api/ng/filter/date

Thanks

Comments

0

Use Angular date filter

Before applying filter you date must be in Javascript Date format or in date timestamp.

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.