码迷,mamicode.com
首页 > Web开发 > 详细

php 时间戳一些示例

时间:2015-07-22 12:35:49      阅读:101      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!