I, timestamp[(M)]
Time stamp. The range is ' 1970-01-01 00:00:00 ' to 2037 years.
The timestamp column records the date and time when it is used for an INSERT or update operation.
If you do not assign a value, the first timestamp column in the table is automatically set to the date and time of the most recent operation.
You can also set the timestamp column to the current date and time by assigning a null value.
The timestamp value returns a string that appears as a ' yyyy-mm-dd HH:MM:SS ' format,
The display width is fixed at 19 characters. If you want to get a numeric value, you should add +0 in the timestamp column.
Second, time
Time. The range is ' -838:59:59 ' to ' 838:59:59 '.
MySQL displays the time value in ' HH:MM:SS ' format, but allows a string or number to be used to assign a value to the time column.
Use Now () to display ' HH:MM:SS '
Use Unix_timestamp () to display ' -838:59:59 ' to ' 838:59:59 '.
mysql> insert into Pluralpoem (title, Create_time) VALUES ("Chunxiao", Unix_timestamp ());
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> insert into Pluralpoem (title, Create_time) VALUES ("Hua", now ());
Query OK, 1 row Affected (0.00 sec)
Mysql> select * from Pluralpoem;
+----+------------+-------------+
| ID | Title | Create_time |
+----+------------+-------------+
| 1 | Denggaowan | NULL |
| 2 | Chunxiao | 838:59:59 |
| 3 | Hua | 22:45:33 |
+----+------------+-------------+
3 Rows in Set (0.00 sec)
Third, DATETIME
A combination of date and time.
The scope of support is ' 1000-01-01 00:00:00 ' to ' 9999-12-31 23:59:59 '.
MySQL displays datetime values in ' yyyy-mm-dd HH:MM:SS ' format, but allows you to assign values to datetime columns using strings or numbers.
Timestamp,time,datetime differences in MySQL