This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

formatDate

Formats a date according to locale rules.

See more...

formatDate(value: string | number | Date, format: string, locale: string, timezone?: string): string
      
      formatDate(value: string | number | Date, format: string, locale: string, timezone?: string): string
    

Parameters

value

Type: string | number | Date.

format

Type: string.

locale

Type: string.

timezone

Type: string.

Optional. Default is undefined.

Returns

string

Description

Where:

  • value is a Date, a number (milliseconds since UTC epoch) or an ISO string (https://www.w3.org/TR/NOTE-datetime).
  • format indicates which date/time components to include. See DatePipe for more details.
  • locale is a string defining the locale to use.
  • timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset (e.g. '+0430'). If not specified, host system settings are used.

See DatePipe for more details.