我无法解决这个问题,所以我希望有人能提供帮助。我有一首歌曲,歌曲长度以毫秒为单位。我还有以 DATETIME 格式播放歌曲的日期。我想做的是找出歌曲播放时间还剩多少毫秒。
Example
$tracktime = 219238;
$dateplayed = '2011-01-17 11:01:44';
$starttime = strtotime($dateplayed);
我正在使用以下方法来确定剩余时间,但它似乎不正确。
$curtime = time();
$timeleft = $starttime+round($tracktime/1000)-$curtime;
任何帮助将不胜感激。
为了满足我的需求,我使用了以下方法:
$curTime = microtime(true);
// something time consuming here
...
// get time difference in milliseconds
$timeConsumed = round(microtime(true) - $curTime,3)*1000;
所以,重点是我们在这里使用时间的浮点表示(参见http://php.net/manual/en/function.microtime.php)
希望您能根据您的需要采用它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)