0

I stumble upon a mysql timestamp insert problem with the date value larger than current date now the following step is

CREATE TABLE foo(
`ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`test_time`TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (`ID`)
); 

INSERT INTO foo(test_time) VALUES('2038-01-19 11:14:08'); // fail
INSERT INTO foo(test_time) VALUES('2038-01-19 11:14:07'); // ok
INSERT INTO foo(test_time) VALUES('2038-01-18 23:59:00'); // ok
INSERT INTO foo(test_time) VALUES('2039-01-01 00:00:00'); // fail

fail means the test_time value is 0000-00-00 00:00:00 my timezone is UTC+8 I want to know whether 2038-01-19 11:14:07 is the max timestamp of mysql support,what's the meaningful moment of this time?

clevertension
  • 6,929
  • 3
  • 28
  • 33

1 Answers1

4

To store higher values for dates you must use DATETIME datatype.

TIMESTAMP has a range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC

DATETIME has a range from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'

http://dev.mysql.com/doc/refman/5.5/en/datetime.html

As suggested by @Joachim Isaksson: PHP & mySQL: Year 2038 Bug: What is it? How to solve it?

Community
  • 1
  • 1
Omesh
  • 27,801
  • 6
  • 42
  • 51