Today is April 7th, and the closest the beginning date of the week is April 5
.
How do I programmatically getting the startDay of the current week using PHP ?
I've tried
$dateStartWeek = date('N', strptime('%m-%d-%g', $dateString));
dd($dateStartWeek);
and tried
function getFirstDayOfWeek(DateTime $date, $firstDay = 0) {
$offset = 7 - $firstDay;
$ret = clone $date;
$ret->modify(-(($date->format('w') + $offset) % 7) . 'days');
return $ret;
}
$dateStartWeek = getFirstDayOfWeek(date("y-m-d"));