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啊,不知这段代码有什么逻辑问题?
相关分类