Check out example codes for "ts change date format". It will help you in understanding the concepts better.

Code Example 1

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');
}

Learn ReactJs, React Native from akashmittal.com