宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 个人博客 > javascript

[js]js中把时间currentTime值转为分钟与数数

2016-10-13 00:16:48 点击量:65 标签: 收藏本文

  1. function timeUpdate() { 
  2.             document.getElementById('time').innerHTML = video1.currentTime; 
  3.         } 
  4.  
  5.         function durationChange() { 
  6.             document.getElementById('duration').innerHTML = video1.duration; 
  7.    
  8.         } 
  9.         window.onload = function () { 
  10.             var videoPlayer = document.getElementById("video1"); 
  11.             videoPlayer.ontimeupdate = function() { timeUpdate(); }; 
  12.         } 
  13.   
var hour = Math.floor (video1.duration / 3600);
var other = video1.duration % 3600;
var minute = Math.floor (other / 60);
var second = (other % 60).toFixed (2);
document.getElementById ('duration').innerHTML = hour + '时' + minute + '分' + second + '秒';
ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室