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: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to