If the PHPdate year is too large, the result will be incorrect. how can this problem be solved?

Source: Internet
Author: User
If the PHPdate year is too large, the result will be incorrect. how can this problem be solved? Echo date ('Y-m-d H: I: S', 3356676867 );
Error result: 11:46:11
Correct: 18:14:27

How can I output such an answer.


Reply to discussion (solution)

? Exam: http://blog.csdn.net/fdipzone/article/details/39457681

$ Dt = new DateTime ('@ 3356676867'); echo $ dt-> format ('Y-m-d H: I: s'); // 2076-05-14 10:14:27

? Up ?? Yes? Set ??, So no ?.

$ Dt = new DateTime ('@ 3356676867'); $ tz = timezone_open ('Asia/Shanghai'); $ dt-> setTimezone ($ tz ); echo $ dt-> format ('Y-m-d H: I: s'); // 2076-05-14 18:14:27



Xu said it was correct. if you encounter any problems, please read the manual.
If necessary, you can compile a recursive function by yourself. when the time is greater than the upper limit of the date () function, minus the number of seconds in four years, the result is calculated within the effective range, then add the number of reduced 4 years.

I am very grateful to the two upstairs. I am a beginner and still have many questions.

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.