纪念日倒计时程序

 1 <?
 2     //功能:纪念日倒计时
 3     //时间:2015/05/19
 4     $now = strtotime("now");//获取当前时间
 5     $endtime = strtotime("2015-06-13 13:00:00");//设定考试时间
 6     
 7     $second = $endtime - $now;//考试时间与现在时间的差值
 8     $year = floor($second/3600/24/365);//从差值中算出有多少年
 9     
10     $temp = $second - $year * 3600 * 24 * 365;
11     $month = floor($temp/3600/24/30);//算出月
12     
13     $temp = $temp - $month * 3600 * 24 * 30;
14     $day = floor($temp /3600/24);//算出天
15     
16     $temp = $temp - $day * 3600 * 24;
17     $hour = floor($temp/3600);//算出小时
18     
19     $temp = $temp - $hour * 3600;
20     $minute = floor($temp/60);//算出分钟
21     
22     
23     $second1 = $temp - $minute * 60;//剩下的就是秒了
24     echo "<font size = 40px color = red>";
25     echo "距离六级考试还有{$year}年{$month}月{$day}天{$hour}小时{$minute}分钟{$second1}秒";
26     echo "</font>";

 

posted @ 2015-05-19 17:24  banshaohuan  阅读(365)  评论(0编辑  收藏  举报