Timestamp,time,datetime differences in MySQL

Source: Internet
Author: User
Tags numeric value

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.