1
2content_copy
3
4{{ dateObj | date }} // output is 'Jun 15, 2015'
5{{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
6{{ dateObj | date:'shortTime' }} // output is '9:43 PM'
7{{ dateObj | date:'mm:ss' }} // output is '43:11'
8
1import { DatePipe } from '@angular/common'
2...
3constructor(public datepipe: DatePipe){}
4...
5myFunction(){
6 this.date=new Date();
7 let latest_date =this.datepipe.transform(this.date, 'yyyy-MM-dd');
8}