Reputation: 1
Currently i am working on creating ecommerce website in that on order return section user can only return goods for particular time from the time product was delivered.(Ex. if product is deliver on 10-7-2018
and return day vale in database is 10
than after 20-7-2018
the button of return should hide automatically.
$date1 = date("Y-m-d"); //Current Date
$date3 = $return_days['value']; //Day count value
//echo $date3.'<br>'; //it will print day count value
$date2 = date("Y-m-d", strtotime($num['updated_date'] .'+'.$date3)); // i am adding $date3 and $num['updated_date'] value
if $num['updated_date']
value is 10-7-2018
and $date3
value is 10
than output of $date2
should 20-7-2018
but my code is not giving desired output.
If any body know solution than please help.
Upvotes: 0
Views: 722
Reputation: 1351
You are on the right track, try this code below:
$date1 = date("Y-m-d"); //Current Date
$daysCount = $return_days['value']; //Day count value
$returnDate = date("Y-m-d", strtotime($num['updated_date'] .'+'.$daysCount.' days'));
echo $returnDate;
Upvotes: 0
Reputation: 1267
I think the following code works :
$Date = "2018-08-14"; // your delivery date
$days = "10"; /// extended days
echo date('Y-m-d', strtotime($Date. ' + '.$days.' days')); /// result
Upvotes: 0
Reputation: 5152
You can use DateTime() object and add days using modify()
method like below:
$daysForReturn = 10;
$date = new \DateTime();
$date->modify("+$daysForReturn day");
echo $date->format('Y-m-d'); // Output: 2018-08-24
Upvotes: 1