If I\'ve got a $date YYYY-mm-dd and want to get a specific $day (specified by 0 (sunday) to 6 (saturday)) of the week that YYYY-
$date
YYYY-mm-dd
$day
YYYY-
I think this is what you want.
$dayofweek = date('w', strtotime($date)); $result = date('Y-m-d', strtotime(($day - $dayofweek).' day', strtotime($date)));