Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date format in angular js

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)

like image 446
Prashobh Avatar asked Jul 17 '13 07:07

Prashobh


2 Answers

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

like image 191
rppig Avatar answered Sep 18 '22 11:09

rppig


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)
like image 21
Florian Avatar answered Sep 19 '22 11:09

Florian