Question: > 
> **Possible Duplicate:**  
> 
> [Get first day of week in PHP?](https://stackoverflow.com/questions/1897727/get-first-day-of-week-in-php) 
> 
> 
> 

i have this script that give's me the beginning and the end of the current week:

```
$begweek = (date('l') == 'Monday')?date('Y-m-d'):date('Y-m-d',strtotime('last monday'));
echo $begweek;

echo "<br>";
$endweek = (date('l') == 'Sunday')?date('Y-m-d'):date('Y-m-d',strtotime('Sunday'));
echo $endweek;

```

what i need is a way to find the beginning and the end of any week if i pass a random date, like `$date="2011-11-15"`;

an ideas on what i need to modify in the current script to accommodate this variable?

thanks

Answer: 
The date function takes a second parameters.

**THE CODE**

```
function blah($date){

    $begweek = (date('l', strtotime($date)) == 'Monday')?date('Y-m-d', strtotime($date)):date('Y-m-d',strtotime('last monday', strtotime($date)));
    echo $begweek;

    echo "<br>";
    $endweek = (date('l', strtotime($date)) == 'Sunday')?date('Y-m-d', strtotime($date)):date('Y-m-d',strtotime('Sunday', strtotime($date)));
    echo $endweek;

}

blah("2011-11-15");

```

**THE OUTPUT**

2011-11-14  
2011-11-20
[date](http://php.net/manual/en/function.date.php) takes a second parameter which is a timestamp to get the date of

use [strtotime](http://us3.php.net/manual/en/function.strtotime.php) to get the timestamp.

```
date( 'l', strtotime( $date ) );

```