- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 07:23 PM
Hi,
I am working on an integration for Monthly data trends.
Against an API request to get the Server Uptime value, I am getting result in minutes (80564.478 mins)
My requirement is to push this value in minutes after converting it into days:hours:minutes:seconds in the reporting table.
Can someone please advise how can I convert it into the required format
Regards,
Mahesh
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:43 PM
Hi Maheshwar,
You can simply use the GlideDuration API from ServiceNow as below: it takes milliseconds as input.
var gd = new GlideDuration(80564.478*60*1000); // time in milliseconds
var duration = gd.getDurationValue() + ''; // Output: 55 22:44:28
var finalDuration = duration.split(' ').join(':'); //. Output: 55:22:44:28
Mark my answer as HELPFUL / CORRECT if this help resolve your issue.
Regards,
Vamsi S

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:07 PM
Hi,
Please try below in your script to convert minutes into Day, hours etc:
var time = 80564.478;
var result = Math.floor(time/24/60) + ":" + Math.floor(time/60%24) + ':' + Math.floor(time%60)+':'+Math.floor((time%60)%60);
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:43 PM
Hi Maheshwar,
You can simply use the GlideDuration API from ServiceNow as below: it takes milliseconds as input.
var gd = new GlideDuration(80564.478*60*1000); // time in milliseconds
var duration = gd.getDurationValue() + ''; // Output: 55 22:44:28
var finalDuration = duration.split(' ').join(':'); //. Output: 55:22:44:28
Mark my answer as HELPFUL / CORRECT if this help resolve your issue.
Regards,
Vamsi S