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>
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") }`;
}