Page 1 of 1

ADD DAYS

Posted: Thu Dec 04, 2003 2:12 am
by phppick
I Want to add 30 days to the Current Date. How can i do it?
I got some Date Class in NET but, i don't know how to use it.
Can anybody give me answer??

Thanks

Posted: Thu Dec 04, 2003 5:24 am
by Weirdan
[php_man]explode[/php_man]
[php_man]date[/php_man]
[php_man]mktime[/php_man]

Code: Select all

$date=date("Y-m-d");
 list($year,$month,$day)=explode("-",$date);
 $month_after=date("Y-m-d",mktime(0,0,0,$month,$day+30,$year));
 echo $month_after."\n";

Posted: Thu Dec 04, 2003 9:03 am
by JAM
Or just:

Code: Select all

<?php
    echo date("Y-m-d",mktime (0,0,0,date("m")  ,date("d")+10,date("Y")));
?>

Posted: Thu Dec 04, 2003 12:22 pm
by Chambrln
Or if you are actually wanting to add a month where months change from 30-31 and even 28 at times you should just do

Code: Select all

<?php
echo date("Y-m-d",mktime (0,0,0,date("m")+1,date("d"),date("Y")));
?>