Description

It formats date to a string based format.

Date Format

Year - Year can be like in 3 formats yyyy,yy,y

Month - Month can be like in 4 formats MMMM, MMM, MM, M.

Date - Date can be like in 2 formats dd, d.

Week - Week can be like in 2 formats EEEE, EEE.

Hour - Hour can be like in 4 formats HH, H, hh, h.

Minute - Minute can be like in 2 formats mm, m

Second - Second can be like in 2 formats ss, s

Millisecond - Milliseconds can be represent by ',sss' or '.sss' (e.g. 000-999)
Designations - AM (ante-meridiem) and PM (post-meridiem) can be represent by 'a'.

There are some predefine "localizable formats" to define Date and Time.

How to use date filter in AngularJS

  1. <!doctype html>
  2. <html ng-app>
  3. <head>
  4. <script src="http://code.angularjs.org/1.2.5/angular.min.js"></script>
  5. </head>
  6. <body>
  7. <span ng-non-bindable>{{1288323623006 | date:'medium'}}</span>: {{1288323623006
  8. | date:'medium'}}<br>
  9. <span ng-non-bindable>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span>: {{1288323623006
  10. | date:'yyyy-MM-dd HH:mm:ss Z'}}<br>
  11. <span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>: {{'1288323623006'
  12. | date:'MM/dd/yyyy @ h:mma'}}<br>
  13. </body>
  14. </html>

Output

Date Filter