- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 05:16 AM
Hi All,
Please advise how to convert duration result from second to hh:mm:ss (hours: Minutes: second).
On change script-
Script include -
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 05:37 AM
Hi Radhe,
Replace line 8 in script include with below.
var h = Math.floor(dur / 3600);
var m = Math.floor(dur % 3600 / 60);
var s = Math.floor(dur % 3600 % 60);
var finalis=h +':'+m+':'+':'+s;
return finalis;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 05:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 05:25 AM
Hi Radhe,
input parameter cannot be less than Zero as you are converting the Decimal hh:mm:ss format.
decimalTohhmmss(1.5); //will give you 01:30:00
decimalTohhmmss(0.5); //will give you 00:30:00
decimalTohhmmss(-1.0); //Will give nothing
function decimalTohhmmss(decimal){
if(decimal< 0) // return nothing if the parameter is negative
return;
var totalSeconds = decimal*3600;
var hours = Math.floor(totalSeconds / 3600);
var minutes = Math.floor((totalSeconds - (hours * 3600)) / 60);
var seconds = totalSeconds - (hours * 3600) - (minutes * 60);
// round seconds
seconds = Math.round(seconds * 100) / 100;
var result = (hours < 10 ? "0" + hours : hours);
result += ":" + (minutes < 10 ? "0" + minutes : minutes);
result += ":" + (seconds < 10 ? "0" + seconds : seconds);
return result;
};
I hope it will help you.
Please mark helpful and correct, if applicable.
Thanks..!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 05:37 AM
Could you suggest where i need to type this scripts in Onchange or script include?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 05:37 AM
Hi Radhe,
Replace line 8 in script include with below.
var h = Math.floor(dur / 3600);
var m = Math.floor(dur % 3600 / 60);
var s = Math.floor(dur % 3600 % 60);
var finalis=h +':'+m+':'+':'+s;
return finalis;