Re: Date Functions

From: Date: Mon, 20 Aug 2001 11:34:59 +0000
Subject: Re: Date Functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63491@lists.php.net to get a copy of this message
On Mon, Aug 20, 2001 at 12:12:15PM +0100, Peter Allum wrote: > I am using PHP 4, I have a date which I am adding to a MYSQL db, I have that > bit sorted, I am trying to calculate an 2 expiry dates, one that is 1 year > and 11 months ahead of the 1st date and another that is 2 years ahead of the > 1st date. > > Any Ideas, I have seen lots of scripts for adding days but not months or > years. > Thank you in advance for your reply Peter, For the first date: ----- $month = date("m") + 11; $day = date("d"); $year = date("Y") + 1; $newDate = date("Y-m-d",mktime(0,0,0,$month,$day,$year)); or $newDate = date("Y-m-d",mktime(0,0,0,date("m")+11,date("d"),date("Y")+1)); ----- And for the second date: ----- $month = date("m") + 11; $day = date("d"); $year = date("Y") + 3; $newDate = date("Y-m-d",mktime(0,0,0,$month,$day,$year)); or $newDate = date("Y-m-d",mktime(0,0,0,date("m")+11,date("d"),date("Y")+3)); ----- And that's all you need! -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#63491) next »