Reputation: 389
I'm trying to create a table with default timestamp on MYSQL 5.7.23 (phpmyadmin)
CREATE TABLE mytable(
id MEDIUMINT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
created_at TIMESTAMP DEFAULT '1970-01-01 00:00:01',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY(id)
);
Upvotes: 1
Views: 387
Reputation: 133360
TIMESTAMP value has a range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
so you should use
created_at TIMESTAMP DEFAULT '1970-01-01 00:00:01',
or as suggested by RaymondNijland
created_at TIMESTAMP DEFAULT 0
or change to
created_at datetime DEFAULT '1900-01-01 00:00:01',
https://dev.mysql.com/doc/refman/8.0/en/datetime.html
Upvotes: 1