PHP resolution for more than 2038 years

Source: Internet
Author: User

Question over 2038 years how does PHP handle it?

1 Echo Date // The maximum integer that the date function can handle is 2147483647-"2038-01-19

is 2 of the 31 square-1 to get 2147483647, if more than this value to do? If you still use date, this function will be messed up.

Solution: Use the DateTime class

1 $d=NewDateTime (' @2147493648 ');2 $d->settimezone (NewDatetimezone (' PRC '));3 Echo $d->format (' y-m-d h:i:s ');//2038-01-19 14:00:484 5 Echo";6 7 //in turn, converts the day of the month to an integer8Date_default_timezone_set (' PRC ');9 $d=NewDateTime (' 2038-01-19 14:00:48 ');Ten Echo $d->format (' U ');//2147493648 One  A Echo"

PHP resolution for more than 2038 years

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.