Home > Backend Development > PHP Tutorial > php 团购记时 代码

php 团购记时 代码

WBOY
Release: 2016-06-13 10:29:53
Original
1106 people have browsed it

php 团购倒计时 代码
php 团购倒计时 代码




//$a = strtotime(date("Y-m-d H:i:s"));

$a =  strtotime(date("2012-5-28  17:50:51"));//自定义时间
$b = $a+24*3600;//24小时后的时间戳的值
$d = $a-24*3600;//24小时前的时间戳的值
echo date("Y-m-d H:i:s",$b);//24小时后的时间
echo "";
echo date("Y-m-d H:i:s",$d);//24小时前的时间
echo "";
$c=mktime();//当前时间戳值
echo date("Y-m-d H:i:s");//当前时间
echo "";
echo $c;//当前时间戳值
echo "";
echo(strtotime("+5 hours")); //5小时后的时间戳值
echo "";
$f=$b-$c;
echo  strtotime(date("Y-m-d H:i:s",$f));//离24小时后的剩余的时间戳。(秒)
echo "";

///$days;
//$hours;
//$minute;
//$second;



$seconds=$f;
//$seconds=3722;

$second=$seconds%60;

$minute=(int)($seconds/60);
//$minute=var_dump((int) ($seconds/60));测试代码
//echo $minute;
//echo (int)$chushu;

$minutes=$minute%60;
$hours=(int)($minute/60);

if($seconds>60){
if($minute>60){
echo '剩余时间:  ';
echo $hours.'小时'.$minutes.'分'.$second.'秒';

}
else{
echo $minutes.'分'.$second.'秒';
}
}else{
if($f else{
echo $seconds.'秒';
}
}



?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template