There's more than likely going to be a duplicate for this question, but I'm struggling to find a precise answer for my problem.
The user enters a starting date for a client's rent (on a form on a previous page), then it needs to generate the next date (one week later) that the client is required to pay. For example:
$start_date = $_POST['start_date'];
$date_to_pay = ???
Lets say the user enters in 2015/03/02:
$start_date = "2015/03/02";
I then want the date to pay to be equal to a week later (2015/03/09):
$date_to_pay = "2015/03/09";
How would one go around doing this? Many thanks.
Just do: $date = strtotime("+7 day"); echo date('M d, Y', $date);
PHP date_add() Function $date=date_create("2013-03-15"); date_add($date,date_interval_create_from_date_string("40 days")); echo date_format($date,"Y-m-d");
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.
You can use this:
$startdate = $_POST['start_date'];
$date_to_pay = date('Y/m/d',strtotime('+1 week',$startdate));
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