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

php 根据当日时间,计算出本日,周,月,季,年,时间戳范围

时间:2018-06-29 14:20:02      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:div   star   ==   时间   时间戳   tar   mkt   bsp   lse   

if( $type == 1) {//当天
            $time[‘start‘] = mktime(0, 0, 0, date(‘m‘), date(‘d‘), date(‘y‘));
            $time[‘end‘] = mktime(0, 0, 0, date(‘m‘), date(‘d‘) + 1, date(‘y‘))-1;
        }else if($type==2){
           //
           $time[‘start‘]  = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
           $time[‘end‘] = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
           
        } else if($type==3){
            //
            $time[‘start‘] = mktime(0, 0 , 0,date("m"),1,date("Y"));
            $time[‘end‘] = mktime(23,59,59,date("m"),date("t"),date("Y"));
        }else if($type == 4){
            //季度
            $season = ceil((date(‘n‘))/3);//当月是第几季度
            $time[‘start‘] =  mktime(0, 0, 0,$season*3-3+1,1,date(‘Y‘));
            $time[‘end‘]  = mktime(23,59,59,$season*3,date(‘t‘,mktime(0, 0 , 0,$season*3,1,date("Y"))),date(‘Y‘));
        }else if($type == 5 ){
            //
            $time[‘start‘] =  mktime(0, 0, 0,1,1,date(‘Y‘));
            $time[‘end‘]  = mktime(23,59,59,12,31,date("Y"));
        }

 

php 根据当日时间,计算出本日,周,月,季,年,时间戳范围

标签:div   star   ==   时间   时间戳   tar   mkt   bsp   lse   

原文地址:https://www.cnblogs.com/fudongdong/p/9242813.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!