Need to add a specified numbers of days to a selected date. Not the current date. Im using strtotime in this fashion:
$date = $_POST['r_date'];
$r_date = $date;
$txts_rental = $_POST['txts_rental'];
switch ($txts_rental){
case "250.00":
$s_length = "30";
break;
case "575.00":
$s_length = "90";
break;
case "975.00":
$s_length = "180";
break;
case "1200.00":
$s_length = "365";
break;
}
$rn_date = date( "Y-m-d", strtotime( "$s_length day" ) );
the date( "Y-m-d"
needs to be the the $r_date
variable in order to get the renewal date from the inputted date
You can use
$EndDateTime = DateTime::createFromFormat('d/m/Y', "16/07/2017");
$EndDateTime->modify('+6 days');
echo $EndDateTime->format('d/m/Y');
or
$today = "2015-06-15"; // Or can put $today = date ("Y-m-d");
$fiveDays = date ("Y-m-d", strtotime ($today ."+5 days"));
You need to change your method as below. add the target date in second parameter so that the date not added in current date
$date = $_POST['r_date'];
$r_date = $date;
$txts_rental = $_POST['txts_rental'];
switch ($txts_rental){
case "250.00":
$s_length = "30";
break;
case "575.00":
$s_length = "90";
break;
case "975.00":
$s_length = "180";
break;
case "1200.00":
$s_length = "365";
break;
}
$rn_date = date( "Y-m-d", strtotime( "$date +".$s_length." day" ) );