title: Get last Sunday date in PHP
body: <p>I am using a <strong>cron job</strong> to generate weekly reports on my database. Basically, the report generation script is in PHP. I scheduled a daily cron job. </p>
  
  <p>My week for the reporting starts on Sunday.</p>
  
  <p>I only want the report generation script to generate report, for the previous week from previous Sunday through to previous Monday.</p>
  
  <p>Take for example. </p>
  
  <blockquote>
    <p>Today is 4 March 2013. When the script runs, it should generate the
    report for 24 Feb 2013 to 3 March 2013. Tomorrow, when the script
    runs, it should also only run the report for 24 Feb 2013 to 3 March 2013.</p>
  </blockquote>
  
  <p>How can I get last <strong>Sunday's date</strong>, automatically in my script?</p>
  
  <p>Currently, I hard code using the following:</p>
  
  <pre><code>$startDate = strtotime("13 January 2013");
  
  $strStartDate = date ("Y-m-d 00:00:00", $startDate);
  $strEndDate = date ("Y-m-d 23:59:00", $startDate + (6*24*60*60));
  </code></pre>
  
  <p>Any help is much appreciated. Thank you.</p>