From 91f169460e3a6d5db0d2bc95d853c0a592be1f04 Mon Sep 17 00:00:00 2001 From: Oliver Kaufmann Date: Thu, 25 Jun 2020 02:09:00 +0200 Subject: [PATCH] fix remaining time calculation --- app/Client/Client.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Client/Client.php b/app/Client/Client.php index 685467a..11099f2 100644 --- a/app/Client/Client.php +++ b/app/Client/Client.php @@ -108,10 +108,11 @@ class Client $this->loop->addPeriodicTimer(1, function () use ($data, $timeoutSection) { $this->timeConnected++; - $carbon = Carbon::createFromFormat('s', str_pad($data->length * 60 - $this->timeConnected, 2, 0, STR_PAD_LEFT)); + $secondsRemaining = $data->length * 60 - $this->timeConnected; + $remaining = Carbon::now()->diff(Carbon::now()->addSeconds($secondsRemaining)); $timeoutSection->clear(); - $timeoutSection->writeln('Remaining time: '.$carbon->format('H:i:s')); + $timeoutSection->writeln('Remaining time: '.$remaining->format('%H:%I:%S')); }); });