[英]How can I calculate the difference between two times that are in 24 hour format which are in different dates?
[英]How to get time difference between 2 times which are in 24 hours format in angular2
我想以24小时格式计算两次之间的时差。 假设开始时间为23.00 PM,结束时间为2.00 AM。 然后它应该显示3个小时。
谁能帮我怎么做。
要比较日期,最好的方法是将getTime()
函数与日期结合使用。
const diffInMilliseconds = endTime.getTime() - starTime.getTime() // 10800000
const diffInHours = diffInMilliseconds / 3600000 // 3 hours
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.