tags:

views:

27

answers:

1

if i have a date 10/10/2009 and i wanted to add strtotime(+# months) to display an expiration date?

the 10/10/2009 is a start date which is imputed by the customer and the +# months is how ever many months were added for a specific product to display the expiration date.

how would i add the two to find the expiration date?

+2  A: 

This tutorial helped me with exactly this kind of problem recently.

$date = "2009-10-10";
$newdate = strtotime ("$date +3 month") ;
$newdate = date ( 'Y-m-j' , $newdate );

echo $newdate;
Adriano Varoli Piazza
Note that you don't need the secondary strtotime(): `echo date('Y-m-d', strtotime('2009-10-10 + 3 months'));` yields '2010-01-10'.
mr. w
Thanks! I'm leaving one extra step so as to make it less perlgolfy.
Adriano Varoli Piazza