[wd_asp elements=’search’ ratio=’100%’ id=1]

Get the start and end dates of a specific week

10th November 2018

Php - Dates & Time

php codehaven

Works out of the box

//start and end dates of a week
function getStartAndEndDate($week, $year) {
$dto = new DateTime();
$dto->setISODate($year, $week);
$ret['week_start'] = $dto->format('Y-m-d');
$dto->modify('+6 days');
$ret['week_end'] = $dto->format('Y-m-d');
return $ret;
}

$week_array = getStartAndEndDate(46,2018);
print_r($week_array);