Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

DATE_PIPE_DEFAULT_OPTIONS

DI token that allows to provide default configuration for the DatePipe instances in an application. The value is an object which can include the following fields:

  • dateFormat: configures the default date format. If not provided, the DatePipe will use the 'mediumDate' as a value.
  • timezone: configures the default timezone. If not provided, the DatePipe will use the end-user's local system timezone.
      
      const DATE_PIPE_DEFAULT_OPTIONS: InjectionToken<DatePipeConfig>;
    

See also

Usage notes

Various date pipe default values can be overwritten by providing this token with the value that has this interface.

For example:

Override the default date format by providing a value using the token:

      
      providers: [
  {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {dateFormat: 'shortDate'}}
]
    

Override the default timezone by providing a value using the token:

      
      providers: [
  {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {timezone: '-1200'}}
]