DateTime Format

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>

I would use date-fns/format here.

I cannot think of a single concept in programming with a bigger gap between how easy people think things should be and how hard they actually are than dates. Pre-unicode multibyte string encoding, URLs, and pattern matching are in the conversation, but dates are a beast.

Do not use JavaScript string manipulation functions on dates.

Any idea on how to format all res.Date at the same time? Cause right now I’m only formatting res[0].Date.
And how to show them in HTML formated in {{item.Date}}?

It is really worth taking the time to go through the Tour of Heroes in its entirety. Pipes are covered in chapter 1.