sam*_*avi 7 javascript time datetime
我创建了一个时间函数来计算媒体播放的时间.它不显示任何前导零.如何让它显示任何前导零?
function converttoTime(timeInSeconds)
{
var minutes = Math.round(Math.floor(timeInSeconds / 60));
var seconds = Math.round(timeInSeconds - minutes * 60);
//var hours = Math.round(Math.floor(timeInSeconds / 3600));
//time = time - hours * 3600;
var time=minutes+':'+seconds;
return time;
}
Run Code Online (Sandbox Code Playgroud)
Ank*_*kur 34
这应该工作:
var time=('0' + minutes).slice(-2)+':'+('0' + seconds).slice(-2);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12353 次 |
| 最近记录: |