All we need is an easy explanation of the problem, so here it is.
I have a date-time data that comes in this format:
I’ve created a MariaDb database and a column for that date of type
However, when inserting the data into the column, I’ll get an exception:
Db error: Incorrect datetime value: 2016-02-10T12:00:00.000Z for column `my_db`.`my_table`.`dt_column`
I’ve tried to replace
'+00:00' — to no avail, the error remained the same.
What’s incorrect about it? Should I tweak the data type of my column somehow?
Or should I preprocess the value itself? How?
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
MySQL/MariaDB are rather lame when it comes to standard date syntaxes. Remove the
REPLACE('...', 'Z', ''))
T may also cause trouble. (
REPLACE('...', 'T', ' '))
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂