Sunday, January 16, 2022

[FIXED] PHP year 2038 problem with 64bit MySQL can't insert date through PHPMyAdmin

Issue

I have a MySQL table which has a column called "created_at" which is a TIMESTAMP field. Whenever I try to insert datetime bigger than 2037 I get the following error:

#1292 - Incorrect datetime value: '2039-06-18 16:54:35' for column 'created_at' at row 1

I get that this a problem with 32bit MySQL but I am running 64bit shouldn't that be the solution?

Here is the output of the command for the version of my MySQL:

mysqld  Ver 5.7.26-0ubuntu0.18.04.1 for Linux on x86_64 ((Ubuntu))

Reading this suggesting that using the TIMESTAMP field is the problem and using DATETIME fields will solve it, is that correct?


Solution

TIMESTAMP remains UNIX TIMESTAMP (32Bit) for compatibility reasons...

The suggestion you've read is correct, use DATETIME instead.



Answered By - Lars Stegelitz

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.