Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Comparison of MySQL date and time types

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "Comparison of MySQL Date and Time Types". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "Comparison of MySQL Date and Time Types" together.

datetime and timestamp

datetime is more like a combination of the time on a calendar and the time on your watch, meaning a specific time.

Timestamp is more suitable for recording time. For example, my time in East 8 District is now 2016-08-02 10:35:52. You are in Japan (East 9 District time is 2016-08-02 11:35:52). I am chatting with you. The database records the time. After taking it out, the time is 2016 -08-02 10:35:52 for me, and 2016-08-02 11:35:52 for you in Japan. So you don't have to worry about time zone calculations.

The time range is timestamp injury (1970-2038), of course datetime (1000-9999) can not record when Liu Bei was born (161 years).

Timestamp and UNIX timestamp

Display intuitive, easy to make mistakes, much better than a lot of very long int numbers

int is cumulative since 1970, but int supports the range 1901-12-13 to 2038-01-19 03:14:07, and needs to be set to bigInt if a larger range is needed. However, this time does not include milliseconds. If milliseconds are required, it needs to be defined as a floating point number. datetime and timestamp come with 6-bit microseconds.

Timestamp is a time-zone conversion, the same as item 2 above.

The time input by the user at the front end is generally a date type. If the int is stored, it needs to be stored before and after processing.

Thank you for reading, the above is the content of "MySQL date and time type comparison", after the study of this article, I believe that everyone has a deeper understanding of MySQL date and time type comparison, the specific use situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report