1
我在php中有以下功能,如何將它轉換爲javascript?javascript長度持續時間
function length_duration ($seconds)
{
$hours = $mins = $sec = NULL;
//for seconds
if($seconds > 0)
$sec = ($seconds % 60 < 10) ? "0".($seconds%60) : ($seconds%60);
//for mins
if($seconds > 60)
$mins = (($seconds/60%60)<10) ? "0".($seconds/60%60).":" : "".($seconds/60%60).":";
//for hours
if($seconds/60 > 60)
$hours = (($seconds/60/60) < 10) ? "0".($seconds/60/60).":" : "".($seconds/60/60).":";
return $hours.$mins.$sec;
}
雙重按位補碼將數字強制爲整數?真有意思。 – 2011-01-27 00:18:02