- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:03 PM
HELP!
I've tried everything I can think of.
All I want to do is to extract two date/time values from my catalog item form and show them in milliseconds.
Nothing seems to work.
Here the last Catalog Client Script I tried:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:25 PM - edited 03-13-2024 08:27 PM
Hi @Joe Taylor you can use below code in client script,
getTime() method returns the value in milliseconds
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:11 PM
@Joe Taylor GlideDateTime is a Server side API and will not work if you will try to use it at the client side. Try creating a script include and call it using GlideAjax and see if it works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:24 PM
Please use client callable script include to get the data:
Client Script:
var reqDateTime = g_form.getValue('request_date_time');
var dueDateTime = g_form.getValue('request_due_date_time');
if (reqDateTime && dueDateTime) {
var ga = new GlideAjax('DateTimeUtil');
ga.addParam('sysparm_name', 'calculateMilliseconds');
ga.addParam('sysparm_reqDateTime', reqDateTime);
ga.addParam('sysparm_dueDateTime', dueDateTime);
ga.getXMLAnswer(function(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
var milliseconds = JSON.parse(answer);
alert("Start Date is: " + milliseconds.reqMilliseconds + " milliseconds");
alert("Due Date is: " + milliseconds.dueMilliseconds + " milliseconds");
});
} else {
alert("Please fill in both Start Date and Due Date fields.");
}
}
Script Include:
function: calculateMilliseconds() {
var reqDateTime= this.getParameter('sysparm_reqDateTime');
var dueDateTime= this.getParameter('sysparm_dueDateTime');
var req = new GlideDateTime();
req.setDisplayValue(reqDateTime);
var due = new GlideDateTime();
due.setDisplayValue(dueDateTime);
var reqMilliseconds = req.getNumericValue();
var dueMilliseconds = due.getNumericValue();
return {
reqMilliseconds: reqMilliseconds,
dueMilliseconds: dueMilliseconds
};
},
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:25 PM - edited 03-13-2024 08:27 PM
Hi @Joe Taylor you can use below code in client script,
getTime() method returns the value in milliseconds
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 06:12 AM
This worked!
So easy now that I know about the getTime() method.
Thanks so much Harish!
var req = g_form.getValue('request_date_time');
var due = g_form.getValue('request_due_date_time');
var ms1 = new Date(req).getTime();
var ms2 = new Date(due).getTime();
alert("Req Time = " + ms1);
alert("Due Time = " + ms2);