在PHP中获取一周中的某一天


Get day of week from yearweek in PHP

我有一个变量$yearweek,我会得到一周中的哪一天:例如:

$yearweek = 201630
$monday   = '2016-07-25'
$thuesday = '2016-07-26'
...
    # Create new DateTime object
    $date = new DateTime();
    # Get Week start date (monday)
    $arr['monday']  = $date->setISODate(2016, 30)->format('d-m-Y');
    # For example this is sunday, you can do this for all days by changing +6
    $arr['sunday']  = $date->modify('+6 days')->format('d-m-Y');