0

In my React project, I am using material-ui TimePicker with momentUtils. Upon selecting a date I am getting the value as a moment object that has the following elements:

_d: _isAMomentObject: _isUTC: _isValid: _locale:

I noticed my date value is coming at the '_d' element in this format:

Tue May 05 2020 11:08:00 GMT+0700 (Indochina Time)

Now I have been trying to save this value on my mysql db, where my field date is of date type and I just keep getting mysql error: "Incorrect date value". So what are considered valid dates on mysql and how can I parse the value I am getting as a valid date before sending it to db?

Thanks in advance.

1 Answer 1

1

Try using momentObj.toISOString() before saving it. Usually it wants it in iso format.

Sign up to request clarification or add additional context in comments.

1 Comment

It parsed the object into the expected format however still getting this error: code: 'ER_TRUNCATED_WRONG_VALUE', errno: 1292, sqlMessage: "Incorrect date value: '2020-05-04T04:47:00.000Z' for column 'user_date' at row 1", sqlState: '22007',

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.