date pipe
This is the documentation for Angular 6.
You can switch to the latest version Angular 10.
You can switch to the latest version Angular 10.
Formats a date value according to locale rules.
Source
<p>Today is {{today | date}}</p>
<p>Or if you prefer, {{today | date:'fullDate'}}</p>
<p>The time is {{today | date:'h:mm a z'}}</p>
export class AppComponent {
today = Date.now();
}
Result
Today is Oct 10, 2020
Or if you prefer, Saturday, October 10, 2020
The time is 4:26 PM GMT+3
Only the en-US
locale data comes with Angular. To localize dates in another language, you must import the corresponding locale data.
Parameters
{{ value_expression | date [ : format [ : timezone [ : locale ] ] ] }}
format
#
format: string = 'mediumDate'
timezone
#
timezone?: string
locale
#
locale?: string