Questions about Countdown in PHP

Source: Internet
Author: User
The countdown problem in PHP
The source code is like this

$time 1=strtotime (Date ("y-m-d h:i:s"));
$time 2=strtotime ("2014-11-11 00:00:00");
$time 3=strtotime ("2013-01-01");
$sub 1=ceil (($time 2-$time 1)/3600);
$sub 2=ceil (($time 3-$time 1)/86400);
echo $time 2. "
";
echo $time 1. "
";
echo "Distance time $sub1";

?>

The result of the final output is
Strict standards:strtotime () [Function.strtotime]: It is not safe to rely on the system ' s timezone settings. Please use the Date.timezone setting, the TZ environment variable or the Date_default_timezone_set () function. In case you used any of those methods and you is still getting this warning, your most likely misspelled the timezone Iden Tifier. We selected ' UTC ' for ' 8.0/no DST ' instead in D:\AppServ\www\base1\strcmp.php on line 18
1415664000
1405231125
Distance Time 2899


The great God, help out.
------Solution--------------------
You have not set the time zone, or the time zone code is wrong
In php.ini
Date.timezone = PRC, GMT
or in the program
Date_default_timezone_set (' PRC ');

------Solution--------------------
Why not?
$time 1=strtotime (Date ("y-m-d h:i:s")); Isn't this today? 2014-07-13
$time 2=strtotime ("2014-11-11 00:00:00");

Isn't there 120 days from 2014-11-11?

------Solution--------------------
You can achieve the exact time of the countdown by making a specific conversion based on your calculated difference.
Can be referred to the following:
http://blog.csdn.net/u011619326/article/details/37740129
  • 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.