var createdDate = g_form.getValue('sys_created_on'); //First Date/Time field
var dttype = 'minute'; //this can be day, hour, minute, second. By default it will return seconds.
var ajax = new GlideAjax('ClientDateTimeUtils');
ajax.addParam('sysparm_name','getNowDateTimeDiff');
ajax.addParam('sysparm_fdt', createdDate);
ajax.addParam('sysparm_difftype', dttype);
ajax.getXMLAnswer(doSomething);
function doSomething(answer){
alert(answer);
}
Calculate the date/time difference between a field on the form and the now date/time ServiceNow
admin Changed status to publish December 26, 2023