How to Use Angular DatePipe

DatePipe is introduced in the @angular/common module. Pipes in Angular can be used to format data such as currenciespercents, **dates, **and more. They are meant to be used in HTML templates like **component.html **file.

Angular DatePipe accepts three parameters.

Primis Player Placeholder

  1. Format
  2. Timezone
  3. Locale
{{ date_Value | date [ : format [ : timezone [ : locale ] ] ] }}

ParameterDescriptionformatYou can pass predefined Angular Date Formats or our custom date format as a parameter.The default value is ‘mediumDate’ (Optional parameter).

timezoneThe default timezone is the local system timezone of the user’s machine.To change the timezone in Angular, pass the timezone offset (‘0530′) or standard UTC/GMT (IST) or continental US timezone abbreviation, and it is an optional parameter.

localeIt represents the locale format rules to use.The default value is our project locale (en_US) if set or undefined. Optional parameter.

Only the en-US locale data comes out of the box with Angular. To localize the dates in another language, you must import relevant to the locale data. See the I18n guide for more information.

Note: The result of this pipe is not reevaluated when the input is mutated. To avoid the need to reformat the Date on every change-detection cycle, treat the Date as an immutable object, and change the reference when the pipe needs to run again.

#angular #dateformat #datepipe #utc

Angular Date Format: How to Use Angular DatePipe
2.60 GEEK