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

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 根据当日时间,计算出本日,周,月,季,年,时间戳范围

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

人吐槽 人点赞

猜你喜欢

发表评论

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:php 根据当日时间,计算出本日,周,月,季,年,时间戳范围