I have an app that allows user to put in a start time and end time. If the end time is into the next day I need to adjust the date. There are currently three input fields, date, battery_start and battery_end.
The battery times are in 24 hour format without the :, i.e. Hm. I am checking to see if the calculation ends up being less than 0, battery_total < 0, and if so I want to set the battery_end to the next day, but with the time the user entered into the field.
/**
* if the flight spans two days, i.e. starts late at night
* and ends early in the morning then adjust datetime
*/
public function adjustFlightTime()
{
//check battery times
if($this->battery_total < 0)
{
$this->battery_end = date('Y-m-d H:m:s', strtotime("$this->battery_end +1 days"));
$this->battery_total = $this->battery_total +24;
}
}
Whenever I try and save the new battery_end time I get an additional 9 minutes added to the time, the date is correct.
DJ