title: PHP date minus X days
body: <p>I have this code in PHP:</p>
  
  <pre><code>date('Y-m-d', strtotime("-7 days"))
  </code></pre>
  
  <p>which i am using in an SQL Query:</p>
  
  <pre><code>$sql="SELECT * from billing_invoices WHERE due_date &lt;= '".date('Y-m-d', strtotime("-7 days"))."' AND (status = 'Unpaid' or status = 'Part Paid') AND statement = '0000-00-00 00:00:00' group by customer_sequence ";
  </code></pre>
  
  <p>so if the date is <code>2014-12-16</code> it will show <code>2014-12-09</code></p>
  
  <p>i want to be able to run this Query too:</p>
  
  <pre><code>$sql="SELECT * from billing_invoices WHERE due_date &lt;= '".date($_POST["date"], strtotime("-7 days"))."' AND (status = 'Unpaid' or status = 'Part Paid') AND statement = '0000-00-00 00:00:00' group by customer_sequence ";
  </code></pre>
  
  <p>but the date being returned is the current day rather than -7 days from the <code>POSTED</code> date</p>