PHP date Year too large results to ask how to solve the exception

Source: Internet
Author: User
PHP date year too big result is wrong how to solve?
This post was last edited by liyuan66 on 2015-03-24 17:31:03

echo Date (' y-m-d h:i:s ', 3356676867);
Error results: 1940-04-08 11:46:11
Correct for 2076/5/14 18:14:27

How can I output such an answer.
------to solve the idea----------------------
Yes, the stickers don't have a setting, so it's not right.


$dt = new DateTime ([email protected] ');
$tz = Timezone_open (' Asia/shanghai ');
$dt->settimezone ($tz);
echo $dt->format (' y-m-d h:i:s '); 2076-05-14 18:14:27

------to solve the idea----------------------


Xu Big said yes, encounter problems more Read the Handbook
If there is a need, you can write your own recursive function, when the time is greater than the date () function, minus the number of seconds of 4 years, into the valid range calculated results, and then how many 4 years to add back
  • 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.