Reputation: 5075
I have react component where I am using useMemo to define table structure. My data is coming via API in DateTime (Web API C#). I tried to use moment to convert date Time format but unable to do so.
current time format without moment 2020-12-18T14:00:00
const scheduleColumns = useMemo(
() => [
{
Header: "Site ID",
accessor: "siteId",
},
{
Header: "Start Time",
accessor: moment("startTime").fromNow(),
},
],
[]
);
..Table
<TableItemsTabs
apiUrl={api.myAPI}
columns={scheduleColumns}
></TableItemsTabs>}
Upvotes: 1
Views: 914
Reputation: 3759
Even found more simpler solution, doesn't even need any module
let a = new Date('2020-12-18T14:00:00');
a.toLocaleString('en-GB');
// Output - "18/12/2020, 14:00:00"
Upvotes: 1