Re: Adding to a Date

From: Date: Sun, 07 Nov 2004 09:41:08 +0000
Subject: Re: Adding to a Date
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201411@lists.php.net to get a copy of this message
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@mattcass.com www.mattcass.com


« previous php.general (#201411) next »