如何将丢失的时间从另一个格式为 (H:i:S) 的 PHP 转换为微时间?

How to get missing time to a microtime from another one, formatted (H:i:S) with PHP?

我是 Whosebug 的新手,我想知道如何从另一个微时间 (true) 开始将丢失的时间日期设置为微时间 (true),并使其格式化为 (H:i:s)。 这是我的代码:

$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

基本上我想获得这种格式的 $rewardCountdown (H:i:s) 我试过并以某种方式得到了类似的东西,但我得到的时间增加而不是减少

当前的 microtime 减去之前的 microtime 将是两次之间经过的秒数的正值。

如果要将秒转换为小时、分钟和秒,只需使用 gmdate

$rewardCountdown = microtime(true) - $this->dailyRewardTime;
$date = gmdate('H:i:s', $rewardCountdown);