MySQL Datetime vs Timestamp
Should I use the datetime or timestamp data type in MySQL?
MySQL Datetime vs Timestamp column types – which one I should use?
Datetime
Timestamp
range
1000-01-01 00:00:00 to 9999-12-31 23:59:59
1970-01-01 00:00:01 to 2038-01-19 03:14:07 UTC(生日和按揭之类的很容易越界)
storage
8 bytes
4 bytes
convertion
不转换 输出是常量
converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval.(MySQL 5 and above)(默认时区是server的,可以按连接配置)
如果用作创建时间和更新时间字段,可以用timestamp;用作一个有意义的字段,用datetime。
Last updated
Was this helpful?