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>

1 Answer 1

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") }`;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.