angular datepipe – Format date as dd/MM/yyyy using pipes

angular datepipe & formatting dates in Angular with examples. Angular Date Pipe allows us to format dates in Angular using the requested format, time zone & local information.

angular datepipe – Angular 10/9/8 Date Pipe Example | Date Pipe in Angular

Angular DatePipe provides different date formats that can be predefined date formats as well as custom date formats. DatePipe is executed only when it detects a pure change to the input value.

{{ value_expression | date [ : format [ : timezone [ : locale ] ] ] }}

Default Example

import { Component } from '@angular/core';
  
@Component({
  selector: 'palainfo-v1',
  template: `<div>
      <p>This Day is : {{ birthDt | date }}</p>
   </div>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  birthDt: number = Date.now();
}

Result

This Day is : Apr 25, 2022

Date Pipe with short, medium, long and full

import { Component } from '@angular/core';
 
@Component({
  selector: 'palainfo-v1',
  template: `<div>
   <p>This Day is Short : {{ birthDt | date: 'short' }}</p>
   <p>This Day is Medium : {{ birthDt | date: 'medium' }}</p>
   <p>This Day is Long : {{ birthDt | date: 'long' }}</p>
   <p>This Day is Full : {{ birthDt | date: 'full' }}</p>
 </div>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  birthDt: number = Date.now();
}

Result

This Day is Short : 4/25/22, 9:54 AM
This Day is Medium : Apr 25, 2022, 9:54:20 AM
This Day is Long : April 25, 2022 at 9:54:20 AM GMT+5
This Day is Full : Tuesday, April 25, 2022 at 9:54:20 AM GMT+05:30

Date Pipe with shortDate, mediumDate, longDate and fullDate

import { Component } from '@angular/core';
  
@Component({
  selector: 'palainfo-v1',
  template: `<div>
   <p>This Day is ShorshortDatet : {{ birthDt | date: 'shortDate' }}</p>
   <p>This Day is mediumDate : {{ birthDt | date: 'mediumDate' }}</p>
   <p>This Day is longDate : {{ birthDt | date: 'longDate' }}</p>
   <p>This Day is fullDate : {{ birthDt | date: 'fullDate' }}</p>
 </div>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  birthDt: number = Date.now();
}

Result

This Day is ShorshortDatet : 4/25/22
This Day is mediumDate : Apr 25, 2022
This Day is longDate : April 25, 2022
This Day is fullDate : Tuesday, April 25, 2022

Don’t Miss : Angular Datepipe In Component

Also Read This πŸ‘‰   how to call one controller from another controller in angularjs?

Date Pipe with shortTime, mediumTime, longTime and fullTime

import { Component } from '@angular/core';
  
@Component({
  selector: 'palainfo-v1',
  template: `<div>
   <p>This Day is shortTime : {{ birthDt | date: 'shortTime' }}</p>
   <p>This Day is mediumTime : {{ birthDt | date: 'mediumTime' }}</p>
   <p>This Day is longTime : {{ birthDt | date: 'longTime' }}</p>
   <p>This Day is fullTime : {{ birthDt | date: 'fullTime' }}</p>
 </div>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  birthDt: number = Date.now();
}

Result
This Day is shortTime : 7:41 AM
This Day is mediumTime : 7:41:04 AM
This Day is longTime : 7:41:04 AM GMT+5
This Day is fullTime : 7:41:04 AM GMT+05:30

Date Pipe with format

import { Component } from '@angular/core';
  
@Component({
  selector: 'palainfo-v1',
  template: `<div>
   <p>This Day is Formate : {{ birthDt | date: 'dd/MM/yyyy hh:mm:ss'  }}</p>
 </div>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  birthDt: number = Date.now();
}

Result

This Day is Formate : 25/04/2022 09:57:27

Date Pipe with timezone

import { Component } from '@angular/core';
  
@Component({
  selector: 'palainfo-v1',
  template: `<div>
   <p>This Day is Formate : {{ birthDt | date: 'dd/MM/yyyy hh:mm:ss' :'UTC' }}</p>
 </div>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  birthDt: number = Date.now();
}

Result

This Day is Formate : 25/04/2022 04:28:31

I hope you get an idea about angular datepipe.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.