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
ADD DAYS
Moderator: General Moderators
[php_man]explode[/php_man]
[php_man]date[/php_man]
[php_man]mktime[/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";Or just:
Code: Select all
<?php
echo date("Y-m-d",mktime (0,0,0,date("m") ,date("d")+10,date("Y")));
?>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")));
?>