php计算时间的应用

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_
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值