6

I am displaying date in this format using angular

{{ date }} ,date:\'MM-dd-yyyy HH:MM:ss\

how to display like Jan-dd-yyyy using angular

Is there any dirct way to do using angular js- (Using normal jquery i am able to do)

Prashobh
  • 9,216
  • 15
  • 61
  • 91
  • Please refer this link friend http://docs.angularjs.org/api/ng.filter:date may be this one help you – snowp Jul 17 '13 at 07:49
  • Hi i created some custom filters and updated here http://www.angulartutorial.net/2014/04/date-filtering-and-formatting-in.html – Prashobh Apr 23 '15 at 06:51

4 Answers4

11

use Angular filter of date.

{{date  | date:'MM-dd-yyyy HH:MM:ss'}}

See the following link.

http://docs.angularjs.org/api/ng.filter:date

rppig
  • 468
  • 3
  • 12
2

Well,

according to the docs, you have a builtin filter in angular, called date:

<p>{{Date.now() | date:'yyyy'}}

would render to:

<p>2013</p>

The yyyyin this case can be any format string documented. In the example you gave, this would be:

{{date | date: 'MMM-dd-yyyy'}} # => "Jan-21-2013" (if date was a date object for this day)
Florian
  • 3,366
  • 1
  • 29
  • 35
2

For custom date:

$scope.user.dob = new Date('1980', '12' ,'10');  // controller code

 {{user.dob | date : 'MMM-dd-yyyy'}}  // Dec-10-1980

For current date:

 $scope.user.current= new Date();  // controller code

 {{user.current | date : 'MMM-dd-yyyy'}}  // Current date in given format
MADHAIYAN M
  • 2,028
  • 25
  • 22
1

Try this

 {{ date }} ,date:\'MMM-dd-yyyy HH:MM:ss\
Amit
  • 15,217
  • 8
  • 46
  • 68