Solution to the problem of timestamp in PHP in 2038

Source: Internet
Author: User
This article mainly introduces how to solve the problem of the timestamp in PHP in 2038. if you need it, you can refer to the typical timestamp range of the valid timestamp in PHP: December 13, 1901 20:45:54 to January 19, 2038 03:14:07 GMT. (The value range is the minimum and maximum values of 32-bit signed integers ). However, before PHP 5.1, this range was limited in some systems (such as Windows) from January 1-20, 1970 to January 19.

The 64-bit system will not be affected. if the 32-bit system is used, the new DateTime solution can be used.

The code is as follows:


$ Date = '2017-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 )),'

';


As there are still a lot of win2003 servers, the applicability of this solution is quite wide and I hope you will like it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.