title: Getting first day of a given month in PHP?
body: <p>I've been trying to get the code below to work, and while it worked with June it is not working with July.</p>
  
  <p>The below results in a value of 3 for $first_day_of_month when it should be 2 for Tuesday.</p>
  
  <pre><code>$date = strtotime('20140702'); // July 02, 2014
  $month = date('m',$date);
  $year = date('Y',$date);
  $days_in_month = date('t',$date);
  $first_day_of_month = date('w', strtotime($year . $month . 01)); // sunday = 0, saturday = 6
  </code></pre>