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');
非常感谢感谢你
还有一个问题 本来明明是除以了3600,按理来说应该显示19小时 可显示的是2899 这么多
为啥呢
$time1=strtotime(date("Y-m-d H:i:s")); //这不是今天吗? 2014-07-13
$time2=strtotime("2014-11-11 00:00:00");
距离 2014-11-11 不是有 120 天吗?
我说那个显示的是2899,,怎么能够转化为120天呢
自己根据你算出的时间差进行具体的转换,就可以实现倒计时的具体时间。
可以大概的参考下这个:
http://blog.csdn.net/u011619326/article/details/37740129

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.
