Home > Backend Development > PHP Tutorial > Solution to solve the problem of timestamp greater than 2038 in PHP_PHP Tutorial

Solution to solve the problem of timestamp greater than 2038 in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:04:52
Original
1065 people have browsed it

Problem handling solution for timestamps greater than 2038 in PHP

The typical range of valid timestamps in PHP is from 20:45:54 on December 13, 1901 to GMT January 19, 2038 03:14:07. (This range conforms to the minimum and maximum values ​​of 32-bit signed integers). However, prior to PHP 5.1 this range was limited to January 1, 1970 to January 19, 2038 on some systems (such as Windows).

64-bit systems will not be affected. If you are using a 32-bit system, you can use new DateTime to solve it

The code is as follows:


$date = '2090-10-01';
$datetime = new DateTime($date);
echo '

Normal time: ', $datetime->format('Y-m-d H:i'), '

';
echo '

Time overflow: ', date('Y-m-d H:i', strtotime($date)), '

';

Since there are still many servers using win2003, this solution has wide applicability. I hope everyone will like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/964005.htmlTechArticleProblem solution for timestamps greater than 2038 in PHP The typical range of PHP valid timestamps is 1901 Greenwich Mean Time From 20:45:54 on December 13, 2038 to 03:14:07 on January 19, 2038. (This model...
source:php.cn
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