Skip to content

Instantly share code, notes, and snippets.

@NachoBrito
NachoBrito / gist:784a10395dfcb989beb7
Created May 27, 2015 07:52
Get week start (monday) and end (sunday) for any given date
function getWeek($d){
$day1 = clone $d;
$day1->setTime(0,0,0);
//If day1 is not a sunday, move it to the next one:
if('Sun' !== $day1->format('D')){
$day1->modify('Sunday');
}
$day0 = clone $day1;
$day0->modify('-6 day');