how to convert string into date format in angular 7 using datepipe code example

Example 1: ts change date format

import { DatePipe } from '@angular/common'
...
constructor(public datepipe: DatePipe){}
...
myFunction(){
 this.date=new Date();
 let latest_date =this.datepipe.transform(this.date, 'yyyy-MM-dd');
}

Example 2: angular date pipe

// In Angular 
// Html
<p>{{myDate | date: 'dd-MM-yyyy'}}</p>
// Typescript
myDate: Date = new Date();

Example 3: show timestamp as yyyy mm dd html angular

{{date  | date:'yyyy-MM-dd'}}