>  기사  >  백엔드 개발  >  php中倒计时的有关问题

php中倒计时的有关问题

WBOY
WBOY원래의
2016-06-13 12:01:54989검색

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

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.