sql - Adding two times together in php when value is greater than 24
I'm trying to add two time variables together, and store this new value in field called timetaken in a SQL table, which works fine unless the total is over 24 hours, in which case it resets. From what I've read and tried so far, this is because it carries over into a day. However I've not managed to come up with a solution.
$timeTakenSoFar is the current
timetaken field from the SQL table.
$timeTaken is taken from a form, which the user inputs in the format
$time = strtotime($timeTakenSoFar) + strtotime($timeTaken) - strtotime('00:00:00'); $totalTimeTaken = date('H:i:s', $time); $stmt = $connection->prepare("UPDATE readings SET timeTaken=? WHERE id=?"); $stmt->bind_param("si", $totalTimeTaken, $id2); $stmt->execute(); $stmt->close();
Thank you in advance for your help!