2

I am trying format the date in the column below as 'DD/MM/YYYY' and also the header row is not aligned with the data, how to fix this?

I am using the function

 function dateFormatter(cell: any) {
        var d = (moment(new Date('${cell}').toLocaleDateString()).format("DD/MM/YYYY"));
        return d;

    }

and in the TableHeaderColumn:

<TableHeaderColumn dataField='effectiveDate' dataSort={true} dataFormat={dateFormatter}  >Effective Date</TableHeaderColumn>
Mostafa
  • 169
  • 1
  • 3
  • 12

1 Answers1

4

Try this - It works in my case

function dateFormatter(cell: any) {
    if (!cell) {
          return "";
    }
    return `${moment(cell).format("DD-MM-YYYY")? moment(cell).format("DD-MM-YYYY"):moment(cell).format("DD-MM-YYYY") }`;
}
Mr. Ratnadeep
  • 591
  • 4
  • 10