How to use angular2 built-in date pipe in services and directives script files [duplicate]

Since CommonModule does not export it as a provider you’ll have to do it yourself. This is not very complicated. 1) Import DatePipe: import { DatePipe } from ‘@angular/common’; 2) Include DatePipe in your module’s providers: NgModule({ providers: [DatePipe] }) export class AppModule { } or component’s providers: @Component({ selector: ‘home’, styleUrls: [‘./home.component.css’], templateUrl: ‘./home.component.html’, … Read more

Format date as dd/MM/yyyy using pipes

Pipe date format bug fixed in Angular 2.0.0-rc.2, this Pull Request. Now we can do the conventional way: {{valueDate | date: ‘dd/MM/yyyy’}} Examples: Current Version: Example Angular 13 Old Versions: Example Angular 8.x.x Example Angular 7.x Example Angular 6.x Example Angular 4.x Example Angular 2.x More info in documentation DatePipe