I get dates from Api in this format 2021-03-18T15:08:52.000Z
and I want it in this format 2021-03-18 15:08
What I’ve tried
API
//GetAllThePdffiles
app.get('/pdffiles', (_req, _res) => {
mysqlConnection.query('Select * from PdfFiles', (err, rows, _fields) => {
if (!err)
_res.send(rows);
else
console.log(err);
})
});
//rows ID,File,Date
.ts file
I tried res[0].Date just to see if it was working but I need the date of all rows
convertDate(date) {
return date && date.length == 24 ? date.substr(0, 10) + ' ' + date.substr(11, 8) : null;
}
getPdfDataBycid(ID){
this.api.getPdfDataByCID(ID).subscribe(res=>{
console.log(res)
this.pdfData = res;
this.modulee = this.convertDate(res[0].Date) ;
})
}
HTML
<p>{{modulee}}</p>
<ion-row *ngFor="let item of pdfData" class="data-row">
<ion-col size="2" *ngIf ="bulkEdit">
<ion-checkbox [(ngModel)] = "edit[i]"></ion-checkbox>
</ion-col>
<ion-col size="4" class="data-col">
<button (click)="getPdfFile(item.File.data)" [(ngModel)]="billid" >{{item.BILL_ID}}</button>
</ion-col>
<ion-col size="4" class="data-col" >
{{ item.Customer_ID }}
</ion-col>
<ion-col size="4" class="data-col">
//this is where i want all Date to show up
{{ item.Date}}
</ion-col>
</ion-row>