Skip to main content

Angular Date Pipe: Formats, Time Zones and Locales

Last updated: September 28, 2026 · Tested with Angular 22.2 (@angular/common) on Node 22

Short answer: the Angular date pipe is {{ value | date:'format':'timezone':'locale' }}. With no arguments it prints mediumDate (Sep 28, 2026). Use a preset such as 'short', 'medium' or 'fullDate' when you want locale-correct output, and a custom pattern such as 'dd/MM/yyyy HH:mm' when the format is fixed by your API or your users. The two mistakes that generate most of the questions about it are passing a non-ISO string (you get NG02311: Unable to convert "28/09/2026" into a date) and forgetting that the pipe converts to the browser's time zone unless you pass one.

This page is a tested reference: one fixed instant (2026-09-28T14:05:09.123Z) formatted with every preset, the useful custom symbols, five time zones and five locales, so you can look up what a pattern prints instead of guessing. It applies to Angular 22 and, since DatePipe has not changed its format grammar since Angular 5, to every version you are likely to be running.

How to Use the Date Pipe in an Angular Component

In a standalone component (the default since Angular 17), import the pipe and use it in the template:

import { Component } from '@angular/core';
import { DatePipe } from '@angular/common';

@Component({
  selector: 'app-order',
  imports: [DatePipe],
  template: `
    <p>Placed: {{ placedAt | date }}</p>
    <p>Placed: {{ placedAt | date:'medium' }}</p>
    <p>Placed: {{ placedAt | date:'dd/MM/yyyy HH:mm' }}</p>
    <p>Placed (UTC): {{ placedAt | date:'medium':'UTC' }}</p>
    <p>Placed (de): {{ placedAt | date:'full':'':'de' }}</p>
  `,
})
export class OrderComponent {
  placedAt = new Date('2026-09-28T14:05:09.123Z');
}

The value can be a Date, a number of milliseconds since the epoch, or an ISO 8601 string. The three arguments are all optional: format (a preset name or a custom pattern), timezone (an offset such as '+05:30' or the string 'UTC'), and locale (a locale code that you have registered). To skip the time zone but set the locale, pass an empty string for the time zone as in the last line above. If you still use NgModules, CommonModule brings the pipe in.

Angular Date Pipe Pre-defined Formats (Real Output)

All rows use the same instant, en-US, and time zone +05:30 so the numbers are comparable:

FormatPattern it expands toOutput
'short'M/d/yy, h:mm a9/28/26, 7:35 PM
'medium'MMM d, y, h:mm:ss aSep 28, 2026, 7:35:09 PM
'long'MMMM d, y, h:mm:ss a zSeptember 28, 2026, 7:35:09 PM GMT+5
'full'EEEE, MMMM d, y, h:mm:ss a zzzzMonday, September 28, 2026, 7:35:09 PM GMT+05:30
'shortDate'M/d/yy9/28/26
'mediumDate' (default)MMM d, ySep 28, 2026
'longDate'MMMM d, ySeptember 28, 2026
'fullDate'EEEE, MMMM d, yMonday, September 28, 2026
'shortTime'h:mm a7:35 PM
'mediumTime'h:mm:ss a7:35:09 PM
'longTime'h:mm:ss a z7:35:09 PM GMT+5
'fullTime'h:mm:ss a zzzz7:35:09 PM GMT+05:30

Prefer the presets when the page is localized. 'shortDate' prints 9/28/26 for en-US but 28/09/2026 for en-GB and 28.09.26 for de, with no code change on your side.

Custom Date Format Patterns

When the format is fixed, build it from these symbols. Output is again for en-US and +05:30:

PatternOutputNotes
dd/MM/yyyy28/09/2026Two-digit day and month
MM/dd/yyyy09/28/2026US order
yyyy-MM-dd2026-09-28ISO date, safe for APIs and sorting
d MMM y28 Sep 2026Single-digit day, short month
EEEE, d MMMM yMonday, 28 September 2026Full weekday and month
EEE, MMM dMon, Sep 28Abbreviated names
MMM yyyySep 2026Month and year only
HH:mm19:3524-hour clock
HH:mm:ss19:35:09
h:mm a7:35 PM12-hour clock with AM/PM
yyyy-MM-dd HH:mm:ss2026-09-28 19:35:09Log-file style
yyyy-MM-ddTHH:mm:ss.SSSZ2026-09-28T19:35:09.123+0530SSS = milliseconds, Z = offset without colon
ww40Week of year
MMMMMSNarrow month, one letter

The symbols you will actually use: y year, M month (MM two digits, MMM Sep, MMMM September), d day, E weekday (EEE Mon, EEEE Monday), H hour 0–23, h hour 1–12, m minute, s second, S fraction of a second, a AM/PM, w week of year, and the four time-zone symbols in the next section. Uppercase Y is the ISO week-numbering year, which differs from y around New Year, so use lowercase y unless you are printing week numbers.

Literal text goes in single quotes. "'Week' w 'of' yyyy" prints Week 40 of 2026, and "d 'de' MMMM 'de' y" with the fr locale prints 28 de septembre de 2026. Without the quotes, d and e would be interpreted as format symbols.

Time Zones: the Same Instant in Four Zones

By default the pipe converts to the browser's time zone, so two users on different continents see different times for the same order. Pass the third argument to pin it:

{{ placedAt | date:'medium':'UTC' }}
{{ placedAt | date:'medium':'+05:30' }}
{{ placedAt | date:'medium':'-07:00' }}
UTC      Sep 28, 2026, 2:05:09 PM
+05:30   Sep 28, 2026, 7:35:09 PM
-07:00   Sep 28, 2026, 7:05:09 AM
+01:00   Sep 28, 2026, 3:05:09 PM

Note that Angular takes a fixed offset (or 'UTC', or 'GMT+2'), not an IANA zone name. When I passed 'Europe/Berlin' it did not throw: it was silently ignored and the output fell back to my machine's zone, which is the worst kind of bug. Daylight-saving changes are therefore your problem: either send the offset from the server with the value, or use Intl.DateTimeFormat with timeZone for zone names. The four zone symbols print the offset in different styles:

SymbolOutput for +05:30
Z+0530
ZZZZZ+05:30
OGMT+5
zzzzGMT+05:30

Locales: Registering and Using Them

Only en-US is available out of the box. For anything else, register the locale data once at startup, then pass the locale as the pipe's third argument or set it app-wide with LOCALE_ID:

// main.ts (or app.config.ts)
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import localeEnGb from '@angular/common/locales/en-GB';
import { LOCALE_ID } from '@angular/core';

registerLocaleData(localeDe);
registerLocaleData(localeEnGb);

export const appConfig = {
  providers: [{ provide: LOCALE_ID, useValue: 'en-GB' }],
};

What 'full' and 'shortDate' print for the same instant in five locales:

en-US   Monday, September 28, 2026, 7:35:09 PM GMT+05:30     9/28/26
en-GB   Monday, 28 September 2026, 19:35:09 GMT+05:30        28/09/2026
en-IN   Monday, 28 September 2026, 7:35:09 pm GMT+05:30      (same as en-GB)
de      Montag, 28. September 2026, 19:35:09 GMT+05:30       28.09.26
fr      lundi 28 septembre 2026, 19:35:09 GMT+05:30          28/09/2026

Skipping registerLocaleData throws NG0701: Missing locale data for the locale "de" at runtime, not at build time, so test at least one page per locale.

Set the Default Format Once With DATE_PIPE_DEFAULT_OPTIONS

If every date in the app should look the same, do not repeat the format in 40 templates. Provide the default once:

import { DATE_PIPE_DEFAULT_OPTIONS } from '@angular/common';

export const appConfig = {
  providers: [
    { provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: { dateFormat: 'dd/MM/yyyy HH:mm', timezone: 'UTC' } },
  ],
};

After that, a plain {{ placedAt | date }} prints 28/09/2026 14:05, and an explicit argument still overrides it where needed.

Using DatePipe in TypeScript (Not Only in Templates)

To format inside a class, for example when building a CSV or a filename, inject the pipe or call formatDate directly. formatDate needs no injection and is what the pipe uses internally:

import { formatDate } from '@angular/common';

const name = `orders-${formatDate(new Date(), 'yyyy-MM-dd', 'en-US')}.csv`;
// orders-2026-09-28.csv

To inject the pipe instead, add DatePipe to the component's providers and call this.datePipe.transform(value, 'medium'). The pipe's transform returns null for null, undefined and empty-string input, which is why templates do not crash on missing data.

Gotchas I Hit While Testing

  • NG02311: Unable to convert "28/09/2026" into a date. The pipe only parses ISO 8601 strings. A value in dd/MM/yyyy from an API or a form throws this at render time. Parse it yourself into a Date first, or have the API return ISO strings.
  • A date-only ISO string is treated as local midnight. '2026-09-28' printed Sep 28, 2026, 12:00:00 AM on my machine (offset +05:30). The same string on a machine west of UTC can display as September 27. Include a time and zone, or format with the 'UTC' argument.
  • The pipe follows the browser's zone by default. Screenshots in bug reports will not match your screen unless the zone is pinned. Pass 'UTC' or set it in DATE_PIPE_DEFAULT_OPTIONS.
  • Unsupported symbols are printed literally. 'Q' for quarter and 'DDD' for day of year are valid in Java and .NET but not here: they came out as Q and DDD. There is no quarter symbol in Angular's DatePipe, so compute it as Math.ceil((month + 1) / 3).
  • formatDate(null, ...) does not return null. The template pipe returns null for a missing value, but the standalone function printed Jan 1, 1970, 5:30:00 AM, the epoch in my zone. Guard the call.
  • Numeric strings are parsed as milliseconds. '1790000000000' formatted fine as Sep 21, 2026, which is convenient until an ID field ends up in a date column.
  • IANA zone names are ignored, not rejected. date:'medium':'Europe/Berlin' renders in the browser's zone with no error. Only offsets, 'UTC' and 'GMT+n' work.
  • 'B' (day period) needs extra locale data. Plain en threw NG02303 for it. Stick to 'a' for AM/PM.

FAQ

How do I format a date as dd/MM/yyyy in Angular? {{ value | date:'dd/MM/yyyy' }}. For the locale's own short form instead, use 'shortDate' with a registered locale.

How do I show the time in 24-hour format? Use HH instead of h: {{ value | date:'HH:mm' }} prints 19:35.

How do I display a date in UTC? Pass the time zone as the second argument: {{ value | date:'medium':'UTC' }}.

Why does the date pipe show yesterday's date? Because a date-only string is parsed as local midnight, and the browser's zone is behind UTC. Send full ISO timestamps and format with an explicit zone.

Can I use the date pipe in a component class? Yes. Inject DatePipe via providers and call transform, or call formatDate from @angular/common directly.

What is the default format of the Angular date pipe? 'mediumDate', for example Sep 28, 2026, unless you change it through DATE_PIPE_DEFAULT_OPTIONS.

Related Angular Guides

Official references: DatePipe API · formatDate · Formatting data based on locale

Comments

Popular posts from this blog

.NET MAUI Tutorial 2026: Build Cross-Platform Apps in C#

Learn .NET MAUI in 2026 to build iOS, Android, Windows & Mac apps from one C# codebase. Start this cross-platform tutorial with code examples today. .NET MAUI (Multi-platform App UI) is Microsoft's framework for building native iOS, Android, Windows, and macOS apps from a single C# codebase . If you've ever wanted to ship a mobile app without learning Swift, Kotlin, and Win32 separately, this .NET MAUI tutorial for 2026 is your starting point. In this guide you'll learn what .NET MAUI is, why it matters for cross-platform app development in C#, and how to build your first working app — with runnable code examples and the best practices senior engineers actually use in production. What Is .NET MAUI and Why Use It in 2026? .NET MAUI is the evolution of Xamarin.Forms, fully integrated into the modern .NET runtime. With one project and one language — C# — you target four platforms. The framework compiles to native UI controls on each device, so a button on iOS...

Angular 14 : 404 error during refresh page after deployment

In this article, We will learn how to solve 404 file or directory not found angular error in production.  Refresh browser angular 404 file or directory not found error You have built an Angular app and created a production build with ng build --prod You deploy it to a production server. Everything works fine until you refresh the page. The app throws The requested URL was not found on this server message (Status code 404 not found). It appears that angular routing not working on the production server when you refresh the page. The error appears on the following scenarios When you type the URL directly in the address bar. When you refresh the page The error appears on all the pages except the root page.   Reason for the requested URL was not found on this server error In a Multi-page web application, every time the application needs to display a page it has to send a request to the web server. You can do that by either typing the URL in the address bar, clicking on the Me...

Angular 14 CRUD Operation with Web API .Net 6.0

How to Perform CRUD Operation Using Angular 14 In this article, we will learn the angular crud (create, read, update, delete) tutorial with ASP.NET Core 6 web API. We will use the SQL Server database and responsive user interface for our Web app, we will use the Bootstrap 5. Let's start step by step. Step 1 - Create Database and Web API First we need to create Employee database in SQL Server and web API to communicate with database. so you can use my previous article CRUD operations in web API using net 6.0 to create web API step by step. As you can see, after creating all the required API and database, our API creation part is completed. Now we have to do the angular part like installing angular CLI, creating angular 14 project, command for building and running angular application...etc. Step 2 - Install Angular CLI Now we have to install angular CLI into our system. If you have already installed angular CLI into your system then skip this step.  To install angular CLI ope...