Home  >  Article  >  Database  >  mysql时间戳溢出问题

mysql时间戳溢出问题

WBOY
WBOYOriginal
2016-06-07 15:33:401817browse

众所周知,时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)以来的秒数。它也被称为 Unix 时间戳(Unix Timestamp)。 mysql也提供了时间戳方面的函数,如unix_timestamp()和from_unixtime()。 现在通用的时间戳貌是32位无符号整形,这也就标示着时间戳会随着

众所周知,时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)以来的秒数。它也被称为 Unix 时间戳(Unix Timestamp)。

mysql也提供了时间戳方面的函数,如unix_timestamp()和from_unixtime()。
现在通用的时间戳貌似是32位无符号整形,这也就标示着时间戳会随着时间的推移将溢出。事实上,时间戳的范围是到2038年止。

如果到了2039年,你的unix_timestamp()函数锁获取的值是多少呢?很简单,把你的系统时间调到2039年,然后重启你的mysql服务,会提示如下提示框:

mysql时间戳溢出问题


再例如:在mysql命令行上输入:select UNIX_TIMESTAMP('2039-01-01'); 得到0

Statement:
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