php中倒计时的问题

清风a50 2014-07-13 02:03:28
源代码是这样的

$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."<br>";
echo $time1."<br>";
echo "距离时间<font color=red>$sub1</font>";


?>

最后输出的结果是
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



那位大神帮忙解决一下哦
...全文
119 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
猪崽儿0o0 2014-07-13
  • 打赏
  • 举报
回复
自己根据你算出的时间差进行具体的转换,就可以实现倒计时的具体时间。 可以大概的参考下这个:
http://blog.csdn.net/u011619326/article/details/37740129
清风a50 2014-07-13
  • 打赏
  • 举报
回复
我说那个显示的是2899,,怎么能够转化为120天呢
xuzuning 2014-07-13
  • 打赏
  • 举报
回复
为啥呢 $time1=strtotime(date("Y-m-d H:i:s")); //这不是今天吗? 2014-07-13 $time2=strtotime("2014-11-11 00:00:00"); 距离 2014-11-11 不是有 120 天吗?
清风a50 2014-07-13
  • 打赏
  • 举报
回复
还有一个问题 本来明明是除以了3600,按理来说应该显示19小时 可显示的是2899 这么多
清风a50 2014-07-13
  • 打赏
  • 举报
回复
非常感谢感谢你
xuzuning 2014-07-13
  • 打赏
  • 举报
回复
你没有设置时区,或时区代码是错误的 php.ini 中 date.timezone = PRC;北京时间 或程序中 date_default_timezone_set('PRC');

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧