Home > Database > Mysql Tutorial > What is the difference between UNIX TIMESTAMPS and MySQL TIMESTAMPS?

What is the difference between UNIX TIMESTAMPS and MySQL TIMESTAMPS?

王林
Release: 2023-09-17 13:49:02
forward
696 people have browsed it

UNIX TIMESTAMPS 和 MySQL TIMESTAMPS 有什么区别?

In MySQL, UNIX timestamps are stored as 32-bit integers. MySQL TIMESTAMPS, on the other hand, are stored in a similar manner but in the human-readable YYYY-MM-DD HH:MM:SS format.

Example

mysql> Select UNIX_TIMESTAMP('2017-09-25 02:05:45') AS 'UNIXTIMESTAMP VALUE';
+---------------------+
| UNIXTIMESTAMP VALUE |
+---------------------+
| 1506285345          |
+---------------------+
1 row in set (0.00 sec)
Copy after login

The above query shows that UNIX TIMESTAMPS values ​​are stored as 32-bit integers with the same range as the MySQL INTEGER data type range.

mysql> Select FROM_UNIXTIME(1506283345) AS 'MySQLTIMESTAMP VALUE';
+----------------------+
| MySQLTIMESTAMP VALUE |
+----------------------+
| 2017-09-25 01:32:25  |
+----------------------+
1 row in set (0.00 sec)
Copy after login

The above query shows that MySQL TIMESTAMPS values ​​are also stored as 32-bit integers, but in a readable format with the same range as the MySQL TIMESTAMP data type range.

The above is the detailed content of What is the difference between UNIX TIMESTAMPS and MySQL TIMESTAMPS?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template