如何使用JavaScript获取两种时间模式之间的差异 [英] How to get difference between two time patterns using javascript
本文介绍了如何使用JavaScript获取两种时间模式之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我不想使用javascript
来获取两种时间模式之间的差异
时间为十进制类型
我想使用javascript
在两个时间之间有区别
请提出解决方案
在此先感谢
问候
Amritha
hi all
i wnt to get difference between two time patterns using javascript
Time is in decimal type
I want difference between two time in time using javascript
Please suggest solution for it
Thanks in Advance
Regards
Amritha
推荐答案
使用JavaScriptDate
对象.使用所需的日期/时间创建其中两个,然后使用valueOf()获取原始数字(自纪元以来的毫秒数).减去它们,因此您有一个以毫秒为单位的时差.除以1000得出间隔(以秒为单位).再除以60会得到分钟...以此类推...
请参见此处 [ ^ ]).
Use JavaScriptDate
objects. Create two of them with the date/times you want, then use valueOf() to get the raw numbers (millisecs since epoch). Subtract them, so you have a time difference in millisecs. Divide by 1000 gives interval in secs. Divide again by 60 gives minutes... and so on...
See here[^] for some how-tos.
这篇关于如何使用JavaScript获取两种时间模式之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文