php算每月天数方法,和十二个月每月开始时间戳和结束时间戳方法

/*算天数*/
       
function is_yue_tian_num($nian,$month){
  if (in_array($month, array(1, 3, 5, 7, 8, 01, 03, 05, 07, 08, 10, 12))) {  
        $text = '31';  
  }elseif ($month == 2){  
              if ($nian % 400 == 0 || ($nian % 4 == 0 && $nian % 100 !== 0)) {        //判断是否是闰年  
                  $text = '29';  
              } else {  
                  $text = '28';  
              }  
          } else {  
              $text = '30';  
          }
          return $text;
    }
   /*$num 月  $type 月开始时间戳start ,结束时间戳end*/
  function start_end_time($num,$type)
  {
    if($num == 1)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,1,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,1,$this->is_yue_tian_num(date('Y'),1),date('Y'));
      }
      
    }

    if($num == 2)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,2,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,2,$this->is_yue_tian_num(date('Y'),2),date('Y'));
      }
      
    }

    if($num == 3)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,3,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,3,$this->is_yue_tian_num(date('Y'),1),date('Y'));
      }
      
    }

    if($num == 4)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,4,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,4,$this->is_yue_tian_num(date('Y'),4),date('Y'));
      }
      
    }

    if($num == 5)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,5,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,5,$this->is_yue_tian_num(date('Y'),5),date('Y'));
      }
      
    }

    if($num == 6)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,6,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,6,$this->is_yue_tian_num(date('Y'),6),date('Y'));
      }
      
    }

    if($num == 7)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,7,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,7,$this->is_yue_tian_num(date('Y'),7),date('Y'));
      }
      
    }

    if($num == 8)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,8,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,8,$this->is_yue_tian_num(date('Y'),8),date('Y'));
      }
      
    }

    if($num == 9)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,9,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,9,$this->is_yue_tian_num(date('Y'),9),date('Y'));
      }
      
    }

    if($num == 10)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,10,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,10,$this->is_yue_tian_num(date('Y'),10),date('Y'));
      }
      
    }

    if($num == 11)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,11,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,11,$this->is_yue_tian_num(date('Y'),11),date('Y'));
      }
      
    }

    if($num == 12)
    {
      if($type == 'start')
      {
        return mktime(0,0,0,12,1,date('Y'));
      }
      else if($type == 'end')
      {
        return mktime(23,59,59,12,$this->is_yue_tian_num(date('Y'),12),date('Y'));
      }
      
    }




    
  }

猜你喜欢

转载自blog.csdn.net/weixin_40896800/article/details/83069074