当前位置:Gxlcms > PHP教程 > php中倒计时的有关问题

php中倒计时的有关问题

时间:2021-07-01 10:21:17 帮助过:19人阅读

php中倒计时的问题
源代码是这样的

$time1=strtotime(date("Y-m-d H:i:s"));
$time2=strtotime("2014-11-11 00:00:00");
$time3=strtotime("2013-01-01");
$sub1=ceil(($time2-$time1)/3600);
$sub2=ceil(($time3-$time1)/86400);
echo $time2."
";
echo $time1."
";
echo "距离时间$sub1";


?>

最后输出的结果是
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 are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in D:\AppServ\www\base1\strcmp.php on line 18
1415664000
1405231125
距离时间2899



那位大神帮忙解决一下哦
------解决方案--------------------
你没有设置时区,或时区代码是错误的
php.ini 中
date.timezone = PRC;北京时间
或程序中
date_default_timezone_set('PRC');

------解决方案--------------------
为啥呢
$time1=strtotime(date("Y-m-d H:i:s")); //这不是今天吗? 2014-07-13
$time2=strtotime("2014-11-11 00:00:00");

距离 2014-11-11 不是有 120 天吗?

------解决方案--------------------
自己根据你算出的时间差进行具体的转换,就可以实现倒计时的具体时间。
可以大概的参考下这个:
http://blog.csdn.net/u011619326/article/details/37740129

人气教程排行