Get first day of week in PHP?


Question

Given a date MM-dd-yyyy format, can someone help me get the first day of the week?

1
117
12/13/2009 9:50:18 PM

Here is what I am using...

$day = date('w');
$week_start = date('m-d-Y', strtotime('-'.$day.' days'));
$week_end = date('m-d-Y', strtotime('+'.(6-$day).' days'));

$day contains a number from 0 to 6 representing the day of the week (Sunday = 0, Monday = 1, etc.).
$week_start contains the date for Sunday of the current week as mm-dd-yyyy.
$week_end contains the date for the Saturday of the current week as mm-dd-yyyy.

134
8/10/2012 4:36:18 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon