Reputation: 476
The query works fine and I'm getting the expected result, but when trying to apply anything to it, it's throwing me this error due to one of the fields:
I've even tried to paste the query result in another file as an object without any extra code, but even then it can't seem to process it properly. It works fine when I'm putting the values of update_date and retrieve_date in quotation marks, but this can't be applicable as I need it as datetime
{
stat: 2,
idusers: 1,
wp_id: 17,
... some more fields...
address: '',
city: '',
signature_name: null,
signature_email: null,
status: 1,
update_date: 2020-10-01T07:47:23.000Z,
retrieve_date: 0999-12-31T21:39:06.000Z,
checking: 1,
UDATE: null
}
what might be the problem? how can I work around it? thanks!
Upvotes: 1
Views: 827
Reputation: 108706
SyntaxError: Invalid or unexpected token is a Javascript error, not a MySQL error. The sample code you showed us defines a Javascript object, but it's invalid.
Why? Javascript doesn't understand a constant of the form 2020-10-01T07:47:23.000Z
. To use constants like that in Javascript, they must be coded as text strings like this. '2020-10-01T07:47:23.000Z'
.
When you hand date / time data off to MySQL, it expects to find it coded as text strings in the format '2020-10-01 07:47:23.000'
. You should do SET time_zone = 'UTC';
right before you hand off this kind of data, because then it will be stored in your TIMESTAMP(3)
column as UTC (Z) time.
Upvotes: 2