Reputation: 960
I am getting this error while trying to modify the values in the following ways
const columns = [
{ label: 'Title', key: 'title' },
{ label: 'Start', key: 'start_time',format: (value, { all_day }) => <span className="start-time">{value.format(timeFormat(all_day))}</span>},
{ label: 'End', key: 'end_time'},
{ label: 'Status', key: 'status', format: (value) => <Status status={value} /> }
]
and this is throwing an error I have mentioned.
where timeFormat
is
const timeFormat = (allDay) => allDay ? 'MM/DD/YYYY' : 'MM/DD/YYYY [@] h:mma
'
Although I am using the same at other positions where it is working fine. Please help where I am doing wrong. I am getting this error while formatting the dates means while showing data in a table this shows the error.
Upvotes: 1
Views: 4048
Reputation: 12954
.format()
is part of Moment.js so you should include it in your app then use it:
const value = "2019-01-16T05:00:00.000Z";
const timeFormat = (allDay) => allDay ? 'MM/DD/YYYY' : 'MM/DD/YYYY [@] h:mma'
console.log(moment(value).format(timeFormat()))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
Upvotes: 3