diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 2ab59d2e8f..a46fe2c19a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -945,9 +945,7 @@ App::post('/v1/functions/:functionId/executions') $execution->setAttribute('stderr', $executionResponse['stderr']); $execution->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { - $created = new DateTime($execution->getCreatedAt()); - $now = Database::getCurrentDateTimeObject(); - $interval = $now->diff($created); + $interval = (new DateTime())->diff(new DateTime($execution->getCreatedAt())); $execution ->setAttribute('time', (float)$interval->format('%s.%f')) ->setAttribute('status', 'failed') diff --git a/app/workers/functions.php b/app/workers/functions.php index 90f12b895e..74304a749d 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -296,9 +296,7 @@ class FunctionsV1 extends Worker ->setAttribute('stderr', $executionResponse['stderr']) ->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { - $created = new DateTime($execution->getCreatedAt()); - $now = Database::getCurrentDateTimeObject(); - $interval = $now->diff($created); + $interval = (new DateTime())->diff(new DateTime($execution->getCreatedAt())); $execution ->setAttribute('time', (float)$interval->format('%s.%f')) ->setAttribute('status', 'failed')