Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- getHourSubHour('13:30', '17:59');
- function getHourSubHour(hs, he)
- {
- var sHour1 = he.split(":");
- var sHour2 = hs.split(":");
- var iSeconds1 = 0;
- var iSeconds2 = 0;
- var iSeconds3 = 0;
- sHour1[0] = parseInt(sHour1[0]);
- sHour2[0] = parseInt(sHour2[0]);
- sHour1[1] = parseInt(sHour1[1]);
- sHour2[1] = parseInt(sHour2[1]);
- iSeconds1 = (sHour1[0] * 3600);
- iSeconds1 += (sHour1[1] * 60);
- iSeconds2 = (sHour2[0] * 3600);
- iSeconds2 += (sHour2[1] * 60);
- iSeconds3 = (iSeconds1 - iSeconds2);
- GetMakeTime(iSeconds3);
- }
- function GetMakeTime(seconds)
- {
- var
- iHours = 0,
- iMinutes = 0,
- iSeconds = seconds,
- sString;
- while (iSeconds > 59)
- {
- iSeconds -= 60;
- ++iMinutes;
- }
- while (iMinutes > 59)
- {
- iMinutes -= 60;
- ++iHours;
- }
- if(iMinutes < 10)
- {
- var sstr1 = '0' + iMinutes;
- }
- if(iHours < 10)
- {
- var sstr2 = '0' + iHours;
- }
- sString = sstr2 + ':' + sstr1;
- alert(sString);
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement