1

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.

7
  • 1
    Edit your question and include all the required information for a Minimal, Complete, and Verifiable example. Commented Apr 17, 2019 at 11:08
  • what is the value's value? Commented Apr 17, 2019 at 11:19
  • I think you have confused Java format with JS. cause your method is ambiguous inside span Commented Apr 17, 2019 at 11:19
  • its a date "2019-01-16T05:00:00.000Z" Commented Apr 17, 2019 at 11:20
  • no @Amir-Mousavi I am using same in other places too Commented Apr 17, 2019 at 11:21

1 Answer 1

3

.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>

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.