PHP计算时间剩余时间

来源:互联网 发布:微信 换手机 数据迁移 编辑:程序博客网 时间:2024/05/18 00:12

 

<body>
<p>1小时=60分钟=3600秒</p>
<p>1天=24 x 3600 = 86400秒 </p>
<p><?php
$endtime="2009-04-08 10:13:00";
$d1=substr($endtime,17,2); //秒
$d2=substr($endtime,14,2); //分
$d3=substr($endtime,11,2); // 时
$d4=substr($endtime,8,2); //日
$d5=substr($endtime,5,2); //月
$d6=substr($endtime,0,4); //年

echo date("Y-m-d H:i:s",time()+3600*8)."n<br>";
echo $endtime.'<br>';
$now_T=mktime();
$now_S=mktime("$d3","$d2","$d1","$d5","$d4","$d6");
echo $now_T."n<br>";
echo $now_S."n<br>";
$end_TS=($now_S-$now_T)/60;   //计算 剩余分钟
echo $end_TS."<br>";

//今天到2009年10月1日还有多少天
$Date_1=date("Y-m-d H:i:s");
$Date_2="2009-04-08 20:20:01";
$d1=strtotime($Date_1);
$d2=strtotime($Date_2);
$Days=round(($d2-$d1)/3600/24);
echo   "今天到{$Date_2}日还有".$Days."天<br><br>";

?></p>