![](/img/trans.png)
[英]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.