title: How to find the first day of the week a given date belongs to?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1897727/get-first-day-of-week-in-php">Get first day of week in PHP?</a>  </p>
  </blockquote>
  
  
  
  <p>Given a timestamp I need to find the first day the week the timestamp belongs to.</p>
  
  <p>e.g.</p>
  
  <pre><code>$format = "first day of week";
  
  //convert to time
  $time = strtotime("2011-07-01 00:00:00");
  
  //format the time to the first day of the week
  $date = strtotime($format,$time);
  
  //Put the first day of the week into a pretty format
  $weekStartDate = date("Y-m-d",$date);
  </code></pre>
  
  <p>The week start should equal 2011-06-27 at the moment its gone horribly wrong and equals 1970-01-01 which suggests to me the “first day of week” format is invalid.</p>
  
  <p>Any ideas would be much appreciated thanks,</p>