MySQL time field data type?

Source: Internet
Author: User
Tags echo date
Previously, the time fields of the data table in the project used int (10). When reading this morning, I suggested using the TIMESTAMP type. How do you store the data in the project? The time fields of the data table in the project used Int (10)
When reading this morning, the book says it is recommended to use TIMESTAMPType. How do you store data in projects?

Reply content:

The time fields of the data table in the project usedInt (10)
When reading this morning, the book says it is recommended to useTIMESTAMPType. How do you store data in projects?

Datetime and int should be less accurate than milliseconds, and timestamp and bigint can

Int occupies 4 bytes, and the 4 bytes are 32-bit. If it is not 32-bit before it is set to 0, the unsigned int (10) in MySQL) the maximum integer that can be stored is 2 ^ 32-1, that is 4294967295.Echo date ('Y-m-d H: I: s', 4294967295 );2106-02-07 14:28:15 is returned, that is, the timestamp after the time cannot be stored in the int (10) field. I personally think that 8-byte bigint can be used to ensure that the time stamp of the earth is stored.

We useDatetimeThe disadvantage is that there is no millisecond and the memory type needs to be recorded in milliseconds.

I personally prefer int-type Timestamp... For details, please come to my friends downstairs...

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.