1import { DatePipe } from '@angular/common'
2...
3constructor(public datepipe: DatePipe){}
4...
5myFunction() {
6 this.date=new Date();
7 const start = this.datepipe.transform(this.date, 'yyyyMMdd\'T\'HHmmss.SSSZ');
8}
9....
10in app.module.com
11import { DatePipe } from '@angular/common'
12...
13providers: [DatePipe]
1#Installation
2$ npm install dateformat
3
4#Usage
5var dateFormat = require("dateformat");
6var now = new Date();
7var today = dateFormat(now, "yyyy-mm-dd");