Page 1 of 1

Adding 1 month to Unix Timestamp

Posted: Fri May 09, 2008 11:18 am
by seodevhead
Hey gang,

I'm trying to figure out how I can add 1-Month on to a "2008-05-09" style date. But I am converting that date to a Unix Timestamp first by doing the following:

Code: Select all

$capturedDate = '2008-06-20';
    $endDate = strtotime($capturedDate);
 
// Now I need to add 1 Month onto $endDate.
Anyone know how I can add 1-month onto $endDate using PHP? I've been looking high and low in the PHP manual under date/time functions, but can't find anything that will do it with a unix timestamp. Thanks for any help.

Re: Adding 1 month to Unix Timestamp

Posted: Fri May 09, 2008 11:35 am
by onion2k
Call strtotime a second time... eg strtotime("+1 month", $endDate); ... you may even be able to do strtotime($captureDate." +1 month");

Re: Adding 1 month to Unix Timestamp

Posted: Fri May 09, 2008 3:26 pm
by seodevhead
Boy... thanks so much Onion! That worked great! I hadn't realized you could double up like that. SWEET! :P