将Spotify的轨道长度转换为分钟和秒

时间:2012-03-13 21:49:23

标签: php spotify

  

可能重复:
  seconds to minutes and days to weeks

我想知道如何将此值转换为分钟和秒:292.96。该值来自this API from Spotify

提前致谢!

2 个答案:

答案 0 :(得分:7)

是的,值,以秒为单位,非常简单;

int minutes = val / 60;
int seconds = val % 60;

答案 1 :(得分:2)

$time = 292.96;
$minutes = floor( $time / 60);
$seconds = $time - ($minutes * 60); // Can add floor() or do mod (%) to round
echo $minutes . ' ' . $seconds; // 4 minutes 52.96 seconds