javasrcipt 计算时间差到毫秒。

1
00:00:13,170 --> 00:00:16,560 //这是字幕里的文件
wheeler introducing
2
00:00:16,560 --> 00:00:29,180
results survival from 7-11 only on ECG
hasn't decided whether he goes in

想计算每条字幕显示的时间

3个回答

 var t1 = "00:00:13,170";
var t2 = "00:00:16,560";
var间隔毫秒数 = parseInt(t2.split(",")[0].split(",")[0]) * 3600000 +
parseInt(t2.split(",")[0].split(",")[1]) * 60000 +
parseInt(t2.split(",")[0].split(",")[2]) * 1000 + 
parseInt(t2.split(",")[1]) -
parseInt(t1.split(",")[0].split(",")[0]) * 3600000 +
parseInt(t1.split(",")[0].split(",")[1]) * 60000 +
parseInt(t1.split(",")[0].split(",")[2]) * 1000 + 
parseInt(t1.split(",")[1]);

kafusky
vineous 谢了,我已经做好了,也是截取字符串,转为int,之后先划成毫秒,再相减/。
大约 4 年之前 回复

转换成秒就除以1000

转换成时间戳的话更方便处理

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问