The date can be converted in typescript to this format 'yyyy-MM-dd'
by using Datepipe
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');
}
and just add Datepipe in 'providers' array of app.module.ts. Like this:
import { DatePipe } from '@angular/common'
...
providers: [DatePipe]