猿问

js 转化当前时间出现的问题?

function toTime(secs) {
  var hours = Math.floor( secs / 3600 ), minutes = Math.floor( secs % 3600 / 60 ), seconds = Math.ceil( secs % 3600 % 60 );
  return ( hours == 0 ? '' : hours > 0 && hours.toString().length < 2 ? '0'+hours+':' : hours+':' ) 
  + ( minutes.toString().length < 2 ? '0'+minutes : minutes ) + ':' + ( seconds.toString().length < 2 ? '0'+seconds : seconds );
 }

我做的一个项目要把audio的当前时间转化成00:00 的形式,所以在网上找了一段代码,
但是出现这种情况

self.$currentTime.text(self.toTime(self.Audio.currentTime));

到一分钟应该 01:00啊,不知这段代码有什么逻辑问题?


鸿蒙传说
浏览 522回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答