I have a string containing 13:00 , i have an duration of 90 for example and i have to convert the duration to hh:mm which i made it. Now i have a string with 1:30. How can i add this 1:30 string to the other 13:00 string so i can compare it with another strings? This is how i conver the duration
var bookH = Math.floor(data[0]['Duration'] / 60);
var bookM = data[0]['Duration'] % 60;
var bookingDurationToHour = bookH + ':' + bookM;
Run Code Online (Sandbox Code Playgroud)
There is momentjs in the project but i still do not know how can i do that.
使用纯 javascript 的解决方案。
var time = "13:00";
var totalInMinutes = (parseInt(time.split(":")[0]) * 60) + parseInt(time.split(":")[1]);
var otherMinutes = 90;
var grandTotal = otherMinutes + totalInMinutes;
//Now using your own code
var bookH = Math.floor(grandTotal / 60);
var bookM = grandTotal % 60;
var bookingDurationToHour = bookH + ':' + bookM;
alert(bookingDurationToHour);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
557 次 |
| 最近记录: |