Re: Adding to a Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matt Cassarino wrote:

Hi,

I am trying to add "x" days to the current date for a calendar program that I am writing.  "x" represents any integer from 1 to 7.  So, for x=4, the program will get the current date

2004-11-06

and add 4 days to it:

2004-11-10

I need it to account for the next month if I want to add 4 days to 2004-11-29, so the result would be 2004-12-03, not 2004-11-33. It would need the same functionality in moving the year to 2005-01-02 when I add 3 days to 2004-12-30.

I hope that I've explained my objective clearly.  I have tried getting the date using

$today = date("Y-m-d");


$timestamp = strtotime('+4 day', date()); // instead of date() you can also provide a different timestamp, for a different base-date
$in4days = date('Y-m-d', $timestamp);


and then trying to add "x" to it, but it only adds "x" to the year, not the day value. So how can I get PHP to add "x" to the day value? Any help would be awesome! Thanks,


Matt

Matt Cassarino
206 484 4626
mc@xxxxxxxxxxxx
www.mattcass.com

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux