Inserting a "date-time" into TIMESTAMP column — "Incorrect datetime value"

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 TIMESTAMP

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 Z with '+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.

Method 1

MySQL/MariaDB are rather lame when it comes to standard date syntaxes. Remove the Z. (REPLACE('...', 'Z', ''))

The T may also cause trouble. (REPLACE('...', 'T', ' '))

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply