Date format in angular js

I display the date in this format using angular

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

how to display as Jan-dd-yyyy using angular

Is there a way to dirct to do using angular js- (using regular jquery that I can do)

+6
source share
4 answers

use angular date filter.

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

See the following link.

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

+11
source

Well,

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

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

will give out:

 <p>2013</p> 

In this case, any format string can be documented yyyy . In the example you specified, this would be:

 {{date | date: 'MMM-dd-yyyy'}} # => "Jan-21-2013" (if date was a date object for this day) 
+2
source

For a personalized date:

 $scope.user.dob = new Date('1980', '12' ,'10'); // controller code {{user.dob | date : 'MMM-dd-yyyy'}} // Dec-10-1980 

The current date:

  $scope.user.current= new Date(); // controller code {{user.current | date : 'MMM-dd-yyyy'}} // Current date in given format 
+2
source

try it

  {{ date }} ,date:\'MMM-dd-yyyy HH:MM:ss\ 
+1
source

Source: https://habr.com/ru/post/949632/


All Articles