First day of last 3 weeks and first day of last 3 months
<p>Am trying to calculate the first day of last 3 weeks and first day of last 3 months in unix timestamp in PHP.</p>

<p>I know I have to use date function but am a bit lost. I do not have PHP 5.3 thus I cannot use relative formats.</p>

<p>Am using the above to decide whether or not to delete a backup. e.g.</p>

<pre><code>if ($time &gt; time()-3600*24*7 &amp;&amp; $time &lt; time()) {
    echo "Keeping: $file&lt;br/&gt;";
}
</code></pre>

<p>I want to keep backups for:</p>

<ol>
<li>Last 7 days</li>
<li>First day of last 3 weeks</li>
<li>First day of last 3 months</li>
</ol>

<p>Am trying to calculate the first day of last 3 weeks and first day of last 3 months in unix timestamp in PHP.</p>

<p>I know I have to use date function but am a bit lost. I do not have PHP 5.3 thus I cannot use relative formats.</p>

<p>Am using the above to decide whether or not to delete a backup. e.g.</p>

<pre><code>if ($time &gt; time()-3600*24*7 &amp;&amp; $time &lt; time()) {
    echo "Keeping: $file&lt;br/&gt;";
}
</code></pre>

<p>I want to keep backups for:</p>

<ol>
<li>Last 7 days</li>
<li>First day of last 3 weeks</li>
<li>First day of last 3 months</li>
</ol>

<p>Update</p>

<p>Adding the solution, as I figured it out with the help of Pekka</p>

<pre><code>$a = (strtotime("last Monday-1 week"));
$b = (strtotime("last Monday-2 week"));
$c = (strtotime("last Monday-3 week"));
$d = (strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
$e = (strtotime('-1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')));
$f = (strtotime('-2 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')));
</code></pre>
