我需要從特定的ISO周開始週一至週五的日期數組。我似乎無法找到返回數組的內建方法。我使用DateTime類與setISODate方法如下:PHP來自ISO周的日期陣列
$bookingDate = new DateTime();
$bookingWeek = $bookingDate->setISODate($bookingDate->format("Y"), $bookingDate->format("W"));
$bookingDates = array();
$mon = $bookingDate->setISODate($bookingDate->format("Y"), $bookingDate->format("W"), 1);
array_push($bookingDates, $mon);
$tue = $bookingDate->setISODate($bookingDate->format("Y"), $bookingDate->format("W"), 2);
array_push($bookingDates, $tue);
$wed = $bookingDate->setISODate($bookingDate->format("Y"), $bookingDate->format("W"), 3);
array_push($bookingDates, $wed);
$thu = $bookingDate->setISODate($bookingDate->format("Y"), $bookingDate->format("W"), 4);
array_push($bookingDates, $thu);
$fri = $bookingDate->setISODate($bookingDate->format("Y"), $bookingDate->format("W"), 5);
array_push($bookingDates, $fri);
print_r($bookingDates);
然而 - 日期的陣列的print_r返回每一天都當作是星期五!有沒有辦法達到我想要的?
檢查我的答案在這裏【計算星期幾給予週數(HTTP的http://stackoverflow.com/a/17065451/212940 – vascowhite
可能重複:// stackoverflow.com/questions/186431/calculating-days-of-week-given-a-week-number) – vascowhite