i am new to stackOverflow, i was wondering how could i get the missing time date to a microtime(true) starting from another microtime(true), and get it formatted like that (H:i:s). This is my code:
$rewardCountdown = microtime(true) - $this->dailyRewardTime; // daily reward is another microtime(true)
$rewardAvailable = $rewardCountdown >= 60 * 60 * 24; // check if 24h are gone so we can get reward
Basically i want to get the $rewardCountdown in this format (H:i:s) I tried and somehow got something like that but i was getting the time increasing instead of decreasing
The current microtime
minus a previous microtime
would be a positive value, of the number of seconds passed between the two times.
If you want to convert seconds into Hours, Minutes and Seconds, you can simply use gmdate
.
$rewardCountdown = microtime(true) - $this->dailyRewardTime;
$date = gmdate('H:i:s', $rewardCountdown);