Rahul Rahul - 6 months ago 27
PHP Question

Add 30 days to date

Hello all i am trying to add 30 days to my date. I am using below coding.

<?php
$next_due_date = date('05/06/2016', strtotime("+30 days"));
echo $next_due_date;
?>


But it is returning to "05/06/2016" only!

Please help me!

Answer

You need to provide date format like d/m/Y instead of 05/06/2016

Try

$old_date = '05-06-2016';
$next_due_date = date('d-m-Y', strtotime($old_date. ' +30 days'));
echo $next_due_date;