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