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...

Kishan
  • 350
  • 2
  • 10
  • 31

4 Answers4

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' }}
evsheino
  • 2,147
  • 18
  • 20
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

Nishant123
  • 1,968
  • 2
  • 26
  • 44
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

Ujjwal kaushik
  • 1,618
  • 11
  • 17
0

Use Angular date filter

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