DatePipe class

Formats a date value to a string based on the requested format.


  • this pipe is marked as pure hence it will not be re-evaluated when the input is mutated. Instead users should treat the date as an immutable object and change the reference when the pipe needs to re-run (this is to avoid reformatting the date on every change detection run which would be an expensive operation).
  • this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera browsers.


$, [format])

where expression is a date object or a number (milliseconds since UTC epoch) and format indicates which date/time components to include:

ComponentSymbolShort FormLong FormNumeric2-digit
eraGG (AD)GGGG (Anno Domini)--
yeary--y (2015)yy (15)
monthMMMM (Sep)MMMM (September)M (9)MM (09)
dayd--d (3)dd (03)
weekdayEEEE (Sun)EEEE (Sunday)--
hourj--j (13)jj (13)
hour12h--h (1 PM)hh (01 PM)
hour24H--H (13)HH (13)
minutem--m (5)mm (05)
seconds--s (9)ss (09)
timezonez-z (Pacific Standard Time)--
timezoneZZ (GMT-8:00)---

In javascript, only the components specified will be respected (not the ordering, punctuations, ...) and details of the formatting will be dependent on the locale. On the other hand in Dart version, you can also include quoted text as well as some extra date/time components such as quarter. For more information see:

format can also be one of the following predefined formats:

  • 'medium': equivalent to 'yMMMdjms' (e.g. Sep 3, 2010, 12:05:08 PM for en-US)
  • 'short': equivalent to 'yMdjm' (e.g. 9/3/2010, 12:05 PM for en-US)
  • 'fullDate': equivalent to 'yMMMMEEEEd' (e.g. Friday, September 3, 2010 for en-US)
  • 'longDate': equivalent to 'yMMMMd' (e.g. September 3, 2010)
  • 'mediumDate': equivalent to 'yMMMd' (e.g. Sep 3, 2010 for en-US)
  • 'shortDate': equivalent to 'yMd' (e.g. 9/3/2010 for en-US)
  • 'mediumTime': equivalent to 'jms' (e.g. 12:05:08 PM for en-US)
  • 'shortTime': equivalent to 'jm' (e.g. 12:05 PM for en-US)

Timezone of the formatted text will be the local system timezone of the end-users machine.


Assuming dateObj is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11) in the local time and locale is 'en-US':

{{ $ }}             // output is 'Jun 15, 2015'
{{ $, 'medium') }}    // output is 'Jun 15, 2015, 9:43:11 PM'
{{ $, 'shortTime') }} // output is '9:43 PM'
{{ $, 'mmss') }}      // output is '43:11'
Implemented types
  • @Pipe('date', pure: true)




hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
supports(dynamic obj) bool
toString() String
A string representation of this object. [...]
transform(dynamic value, [String pattern = 'mediumDate']) String


operator ==(Object other) bool
The equality operator. [...]