Re: 9 Months Ago

From: Date: Sun, 21 Mar 2004 16:08:27 +0000
Subject: Re: 9 Months Ago
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-181086@lists.php.net to get a copy of this message
Marek Kilimajer wrote:
Jeff Oien wrote:
When I do this: $lastmonth = mktime(0, 0, 0, date("m")-9, date("d"), date("Y"));
this will not work most of the year, if current month is August or less, the month value will be negative. Use strtotime('-9 months') instead.
This code works just fine for me: $nine_months_ago = mktime(0, 0, 0, date("m")-9, date("d"), date("Y")); echo date("m/d/Y", $nine_months_ago); If today is March 21, 2004, then this outputs "06/21/2003". That's exactly nine months ago. See http://www.php.net/date -- Regards, Ben Ramsey http://benramsey.com http://www.phpcommunity.org/wiki/People/BenRamsey

« previous php.general (#181086) next »