0

我是stackOverflow的新手,我想知道如何从另一个微时间(真)开始将丢失的时间日期设置为微时间(真),并将其格式化为这样(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

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

4

1 回答 1

0

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

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

$rewardCountdown = microtime(true) - $this->dailyRewardTime;
$date = gmdate('H:i:s', $rewardCountdown);
于 2020-04-05T19:44:20.067 回答