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

What is the difference between UNIX TIMESTAMPS and MySQL TIMESTAMPS?

王林
王林forward
2023-09-17 13:49:02591browse

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)

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)

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!

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