首页 > Web开发 > 详细

php 时间戳一些示例

时间:2015-07-22 12:33:38      阅读:148      评论:0      收藏:0      [点我收藏+]

如根据当前时间 确定本天的起止时间

 // 获取当天的时间段内
  $nowdate = date("Y-m-d",time());
  $begintime = strtotime($nowdate);     //当天的开始 时间戳
  $endtime = $begintime + 60*60*24;  //当天的结束 时间戳
  $map[‘add_time‘] = array(array(‘egt‘,$begintime),array(‘lt‘,$endtime),‘AND‘);

如根据当前时间  确定本月的起止时间

     $nowmonth = date("m",time());         //获取当前月
    if($nowmonth == ‘01‘ || $nowmonth == ‘03‘ || $nowmonth == ‘05‘ || $nowmonth == ‘07‘ || $nowmonth == ‘08‘ || $nowmonth == ‘10‘ || $nowmonth == ‘12‘){
            $nowdate = date("Y-m",time());
            $mstarttime = strtotime($nowdate); //本月的开始 时间戳
            $mendtime = $mstarttime + 31*60*60*24;

   }else if($nowmonth == ‘02‘){
           $nowdate = date("Y-m",time());
           $mstarttime = strtotime($nowdate); //本月的开始 时间戳
           $mendtime = $mstarttime + 28*60*60*24;

  }else if($nowmonth == ‘04‘ || $nowmonth == ‘06‘ || $nowmonth == ‘09‘ || $nowmonth == ‘11‘){

         $nowdate = date("Y-m",time());
         $mstarttime = strtotime($nowdate); //本月的开始 时间戳
         $mendtime = $mstarttime + 30*60*60*24; //本月的结束时间
}

$map[‘add_time‘] = array(array(‘egt‘,$mstarttime),array(‘lt‘,$mendtime),‘AND‘);

php 时间戳一些示例

原文:http://www.cnblogs.com/bingbingde/p/4666892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!