Why can I use the int type for the time field in the mysql database? what are the advantages of the datetime type? What should I do?

Source: Internet
Author: User
Why can I use the int type for the time field in the mysql database? what are the advantages of the datetime type? I have seen some mysql database designs, such as the time field in the phpwind Forum, using int (10 )? It indicates that the time already has the datetime type. why should we use the int type? What are the advantages of doing so? I hope you can give me some advice. Why can I use the int type for the mysql database to indicate the time field? what are the advantages compared with datetime?
I have seen some mysql database designs, such as the time field in the phpwind Forum, using int (10 )? It indicates that the time already has the datetime type. why should we use the int type? What are the advantages of doing so? I hope you can give me some advice ~

------ Solution --------------------
If there is a time zone problem, int type is used ..
If it is easy to read, use the datetime type...
------ Solution --------------------
Because? Phpwind sorting is based on lastpost
Int type is much faster than varchar when the data volume is large

------ Solution --------------------
Possible advantages:
1. sorting well. for example, if I want the latest news records, I just need to sort desc.
2. easy conversion, because INT is in mysql? The timestamp is saved. You do not need to convert the format. Otherwise, the time in PHP and mysql is different, and the access needs to be converted.
If inT is used, the database does not need to be moved? Php.
3. convenient time calculation. The advantage of unix time is that it is calculated by example.

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.