18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to get difference between two times
Hi
Please any one provide me script to calculate difference between two times. The two times are in HH:MM AM/PM format
Please any one provide me script to calculate difference between two times. The two times are in HH:MM AM/PM format
This discussion has been closed.
Comments
You need to write a fresh RegEX to extract HH:MM only.
function timeDifference($t2, $t1){
var $time1 = $t1.split(":");
var $time2 = $t2.split(":");
var $time = (parseInt($time2[0])*3600 + parseInt($time2[1])*60 + parseInt($time2[2])) - (parseInt($time1[0])*3600 + parseInt($time1[1])*60 + parseInt($time1[2]));
var $timeDiff = new Array(3);
$timeDiff[0] = parseInt($time/3600);//hours
$timeDiff[1] = parseInt(($time%3600)/60);//minutes
$timeDiff[2] = ($time%3600)%60;//seconds
return $timeDiff;
}