Get week start and end dates of supplied date week

August 08, 2018171
Share Tweet Pin it

The following PHP code will give the satureday and sunday as the week start and end days of specified week of the supplied date:

$s = 'Monday, September 28, 2018';
$time = strtotime($s);
$start = strtotime('last sunday, 12pm', $time);
$end = strtotime('next saturday, 11:59am', $time);
$format = 'l, F j, Y g:i A';
$start_day = date($format, $start);
$end_day = date($format, $end);
header('Content-Type: text/plain');
echo "Input: $s\nOutput: $start_day - $end_day";

All the best. Happy coding.