"first", 2=>"second", 3=>"third", 4=>"fourth", -1=>"last"); $dayname = array("sun", "mon", "tue", "wed", "thu", "fri", "sat"); //($evento["CalendarioReglas_semana"]) $fechaIni = "2021-02-02 00:00:00"; $semana = 2; /*for($semana = 1; $semana<=4; $semana++){ $d = $diasArr[0]; $fecha = date ("Y-m-01", strtotime($fechaIni)); if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){ echo "
".$fecha."
"; }else{ if(intval(date("w", strtotime($fecha))) == intval($d)){ echo "[".$fecha."]".date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)))."
"; }else{ echo "[".$fecha."]".date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)))."
"; } } }*/ //El bueno $fecha = date ("Y-m-01", strtotime($fechaIni)); while (strtotime($fecha) <= strtotime('2021-06-01')) { foreach($diasArr as $d){ //echo "-->". intval(date("w", strtotime($fecha)))." == ". intval($d)."[".$fecha."]"; if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){ echo "".$fecha."
"; }else{ if(intval(date("w", strtotime($fecha))) == intval($d)){ echo "".date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)))."
"; }else{ echo "".date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)))."
"; } } } $fecha = date ("Y-m-01", strtotime("+1 month", strtotime($fecha))); //echo "".$fecha.""; } /*echo "".$dateObj ->format('m-d-Y')."
"; $dateObj->modify('+1 month'); $dateObj->modify('first mon'); } */