MySQL Time type: DATETIME & TIMESTAMP
Length
- The datetime type contains date and time, range 1000-01-01 00:00:00 ~ 9999-12-31 23:59:59. DateTime can also contain milliseconds, for example, 2018-03-11 14::13:22.999
- Timestamp can also store dates and times, but the range is 1970-01-01 00:00:01 UTC ~ 2038-01-19 03:14:07 UTC
Time
JDBC represents the type of time
The information in this section is a bit old (https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/guide/jdbc/getstart/mapping.doc.html)
These three types are inherited from Java.util.Date because Java.util.Date cannot match three JDBC time types.
The date represents the time type java.sql.Date for SQL date that contains only the month and date (SQL in this case is the SQL-92 standard). The hour, minute, second, millisecond fields of the parent class are set to 0.
Time indicates that only the temporal type of java.sql.Time is included for the duration of information. The year of the parent class, month, the day field is set to 1970, January, number 1th. This time is the "zero era" inside Java.
Timestamp contains Date+time plus a nanosecond (nanosecond) field java.sql.Timestamp for SQL Timestamp information. This type expands the extra nanosecond field for java.util.Date.
Other commands get current Time_zone
SELECT @@global.time_zone, @@session.time_zone;
If the query result is system, indicates that the MySQL server is using the time zone
date -R
command to view the system time zone.
MYSQL Time Type & jdbc Time type