php计算时间的应用主要有如下几个: echo "<br>***************用PHP打印出前一天的时间***************<br>"; echo date("Y-m-d ",strtotime(" -1 day"));//昨天 echo '<br>'; echo date("Y-m-d ",strtotime(" +1 day")); //明天 echo "<br>********************输出当前时间*********************<br>"; echo date("Y年m月d日 l H:i:s A"); //2011年08月29日 Monday 04:52:25 AM echo '<br>'; echo date("y-n-j D h:i:s a"); //11-8-29 Mon 04:52:25 am echo '<br>'; echo date("Y年n月j日 l G:i:s a",strtotime("now"));//2011年8月29日 Monday 7:56:05 am echo "<br>*****************两个日期之间的天数******************<br>"; $str1=strtotime("2007-02-08"); $str2=strtotime("now"); print_r (floor(($str2-$str1)/(3600*24))); echo "<br>**********************倒计时*************************<br>"; $time1=strtotime("2012-7-18 17:30:00"); $time2=strtotime("now"); $sec=$time1-$time2; $year=floor($sec/3600/24/365);//年 $temp=$sec-$year*365*24*3600; $month=floor($temp/3600/24/30);//月 $temp=$temp-$month*30*24*3600; $day=floor($temp/3600/24);//日 $temp=$temp-$day*3600*24; $hour=floor($temp/3600);//小时 $temp=$temp-$hour*3600; $minute=floor($temp/60);//分 $second=$temp-$minute*60;//秒 echo "距离培训毕业还有".$year."年".$month."月".$day."天".$hour."小时".$minute."分".$second."秒";
转载:http://zhidao.baidu.com/link?url=EKyctDdJ4TBiDOvQBzlN17IWRg24yxymDxVZi24vMlzt3KmidML0iZNgb3zIrJgqraGa69uGH8746AHAimjcW_