title: filtering by date php for this month and last x days and this week
body: <p>I have a date that returns in a string as 2012-03-19 05:00:32, its not coming from the database</p>
  
  <p>I can use below to search for the last 30 days</p>
  
  <pre><code>$date = '2012-03-19 05:00:32';
  if (strtotime($date) &gt;= strtotime('-7 days')) {
  // do something
  }
  </code></pre>
  
  <p>Problem is if today is the 19th March, i was to search from the 11th to the 18th for the last 7 days and that seems to search for the last 7 days by calculating 24 hours * 7 by my searches need to start from 00:00:01 each day.</p>
  
  <p>My plan is to break the date down into Year, Month and Day then check if year = 12, then check if month = 3, then check if date between 11 and 18.</p>
  
  <p>Im just wondering if there is a more efficient way to do this or if im on the right track.</p>
  
  <p>I also have the same issue with running a search on all info from this month and also want to search for all info this week starting on Monday.</p>
  
  <p>So this is just asking if my method is sound or if there is a more efficient method.</p>