Get all days and date for a given month

后端 未结 9 1669
天涯浪人
天涯浪人 2021-02-10 08:17

Would like to retrieve all days and date for a given month. Have this currently which shows all the days for the current month, but how do I parse in a specified month instead?<

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-10 08:53

    $c_year = date("Y");
    $c_month = date("m");
    $no_day = cal_days_in_month(CAL_GREGORIAN, $c_month, $c_year);           
    for($i=1; $i<=$no_day; $i++){ 
         $cd[] .= $c_year.'-'.$c_month.'-'.$i;
    }
    $date_val = json_encode($cd) 
    print_r($date_val); // date array
    

提交回复
热议问题