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


app.get('/pdffiles', (_req, _res) => {
    mysqlConnection.query('Select * from PdfFiles', (err, rows, _fields) => {
        if (!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;

      this.pdfData = res;
      this.modulee = this.convertDate(res[0].Date) ;



<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 size="4"  class="data-col">
      <button (click)="getPdfFile(" [(ngModel)]="billid" >{{item.BILL_ID}}</button>
    <ion-col size="4"  class="data-col" >
      {{ item.Customer_ID }}
    <ion-col size="4" class="data-col">
//this is where i want all Date to show up
      {{ item.Date}}

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.