The difference between datetime and timestamp

DATETIME
A combination of date and time. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. MySQL displays DATETIME values ​​in the 'YYYY-MM-DD HH:MM:SS' format, but allows strings or numbers to be used to assign values ​​to DATETIME columns.
TIMESTAMP[(M)]
Timestamp . The range is '1970-01-01 00:00:00' to 2037.
TIMESTAMP columns are used to record the date and time during INSERT or UPDATE operations. If you don't assign a value, the first TIMESTAMP column in the table is automatically set to the date and time of the most recent operation. It is also possible to set a TIMESTAMP column to the current date and time by assigning a NULL value.

After the TIMESTAMP value is returned, it is displayed as a string in the format of 'YYYY-MM-DD HH:MM:SS', and the display width is fixed to 19 characters. If you want to get a numeric value, you should add +0 to the TIMESTAMP column.

Note: The TIMESTAMP format used before MySQL 4.1 is not supported in MySQL 5.1; see the MySQL 4.1 Reference Manual for information on the older format.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326118533&siteId=291194637