Is there any php function available where I can add days to a date to make up another date? For example, I have a date in the following format: 27-December-2011
If I add 7 to the above, it should give: 03-January-2012.
Many thanks
var myDate = new Date(new Date(). getTime()+(5*24*60*60*1000));
echo date ( 'Y-m-d' , strtotime ( $Date . ' + 10 days' )); ?> Method 2: Using date_add() Function: The date_add() function is used to add days, months, years, hours, minutes and seconds.
Try this
$add_days = 7;
$date = date('Y-m-d',strtotime($date) + (24*3600*$add_days));
Look at this simple snippet
$date = date("Y-m-d");// current date
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With