Home  >  Article  >  Database  >  What are the MySQL date and time data types?

What are the MySQL date and time data types?

WBOY
WBOYforward
2023-06-03 18:22:292562browse

MySQL date and time data type

1. datatime and date

Datetime format: year-month-day hour: minute: second Support range 1000-01-01 00:00:00 To 9999-12-31 23:59:59

 2. timestamp timestamp

Datetime and timestamp types behave the same, their difference is:

datetime From 1-9999, and timestamp from 1970-2038 (the reason is that timestamp occupies 4 bytes, the same as the integer range, the number of seconds after 11:14:07 on January 19, 2038 exceeds 4 bytes Section length)

 3. year

 Can only represent years between 1901-2155, because it only occupies 1 byte and can only represent 255 numbers.

 4. time

 Can represent time or time interval, range -838:59:59-838:59:59

The above is the detailed content of What are the MySQL date and time data types?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete