Usually the datetime type is used to store time. Now many systems also use int to store time. What is the difference between them? My summary is as follows:
int
(1). 4 bytes of storage. The length of INT is 4 bytes. The storage space is less than datatime. The int index storage space is also relatively small, and the sorting and query efficiency are relatively high. A little higher
(2) The readability is extremely poor and the data cannot be seen intuitively, which may make you very annoyed
TIMESTAMP
(1) 4 bytes storage
(2) The value is saved in UTC format
(3) Time zone conversion, convert the current time zone when storing, and convert back to the current time zone when retrieving.
(4) TIMESTAMP value cannot be earlier than 1970 or later than 2037
datetime
(1) 8 bytes storage
(2) Independent of time zone
(3) Ended with 'YYYY-MM-DD HH Retrieve and display DATETIME values in :MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
mysql has only become popular in the past two years, and its performance is getting better and better. How to store it depends on the individual. Habits and project needs