我是stackOverflow的新手,我想知道如何将丢失的时间日期从另一个microtime(true)开始转换为microtime(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
基本上我想以这种格式(H:i:s)获得$ rewardCountdown我尝试了一下,得到了类似的结果,但是我得到的是增加而不是减少的时间
当前microtime
减去前一个microtime
将是两次之间经过的秒数的正值。
如果要将秒转换为小时,分钟和秒,则只需使用gmdate
。
$rewardCountdown = microtime(true) - $this->dailyRewardTime;
$date = gmdate('H:i:s', $rewardCountdown);