Im working on a uni project for a simple car rental system. My problem arises when calculating the time (number of days and hours for car rental).
Now is the time (where am I) 12:15 pm
CODE:
$ciDate = '2016-08-28';
$ciTime = '13:10';
$calcDate = $ciDate.$ciTime;
$calcDate = strtotime($calcDate);
$remaining = $calcDate - time();
$days_remaining = floor($remaining / 86400);
$hours_remaining = floor(($remaining % 86400) / 3600);
$totPrice = $days_remaining * 4;
echo $days_remaining. ' Days and ' . $hours_remaining. ' hours';
MY PROBLEM
When the above code is executed, I will return 2 days and 5 hours , which is wrong, given that my time is now 12:15 PM 2016/08/26
I'm going to go on a limb here and guess the problem is that the server time is different from my current time?
Any suggestions on how to fix the above problem are greatly appreciated.
EDIT:
At the time of writing, the correct result should be 2 days and 1 hour
source
share