$time1 = new DateTime('2022-05-05 11:54:48'); $time2 = new DateTime('2022-05-05 12:00:48'); $diff = $time2->diff($time1); $time_spent = $diff->format("%H:%I:%S"); echo $time_spent; //Jerespy