zoukankan      html  css  js  c++  java
  • PHP获取指定时间的前6个月月份、获取前6天日期、获取当月日期

    //获取前6个月月份
        public  function to_sex_month(){
            $today = input('param.today') ? input('param.today') : date("Y-m-d");
            $arr = array();
            $old_time = strtotime('-6 month',strtotime($today));
            for($i = 0;$i <= 6; ++$i){
                $t = strtotime("+$i month",$old_time);
                $arr[]=date('Y-m',$t);
            }
            return $arr;
        }
    
        //获取前6天日期
        public  function to_sex_day(){
            $today = input('param.today') ? input('param.today') : date("Y-m-d");
            $arr = array();
            $old_time = strtotime('-6 day',strtotime($today));
            for($i = 0;$i <= 6; ++$i){
                $t = strtotime("+$i day",$old_time);
                $arr[]=date('Y-m-d',$t);
            }
            return $arr;
        }

     获取当月日期

    /**
     * 获取当前月的所有日期
     * @return array
     */
     private function getMonthDays()
     {
         $monthDays = [];
         $firstDay = date('Y-m-01', time());
         $i = 0;
         $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day"));
         while (date('Y-m-d', strtotime("$firstDay +$i days")) <= $lastDay) {
             $monthDays[] = date('Y-m-d', strtotime("$firstDay +$i days"));
             $i++;
         }
         return $monthDays;
     }
  • 相关阅读:
    Lesson 61-62 Are Relatives Important to You?
    Lesson 59-60 Househusband
    Lesson 57-58 Cosmetic Surgery
    Lesson 55-56 TV Commercials
    Blash
    高维宇宙
    巴卡尔
    完美标号
    小A点菜(luogu 1164)简单DP
    聪明的质监员(qc)
  • 原文地址:https://www.cnblogs.com/houdj/p/11211181.html
Copyright © 2011-2022 走看看