Issue in calculating time difference in different timezone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 11:14 PM
Hi Team,
My system timezone is in EST and servicenow timezone is in IST. Below are the script which calculate time difference but its not working properly.
Catalog Client Script:-
BIIB_CPGResizeConfirmDate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
chkCurrDate: function() {//Check if given Date time is in past or not.
var ActualEndDate = this.getParameter('sysparm_time');
var dif = gs.dateDiff(gs.nowDateTime(), ActualEndDate, true);
if (dif < 1800) {
return false;
} else {
return true;
}
},
chkstartstopDate: function() {//Check if given Date time is in past or not for start stop.
var ActualEndDate = this.getParameter('sysparm_time');
var dif = gs.dateDiff(gs.nowDateTime(), ActualEndDate, true);
if (dif < -2) {
return false;
} else {
return true;
}
},
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 03:22 AM
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 05:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 06:04 AM
Hi,
why not use UI policy and no scripting will be required?
Something like this; it's just an example. Please enhance it
Start Time [After] Today
function onCondition() {
// valid
alert('Start date cannot be in future');
g_form.showErrorBox('start_date_time','Invalid');
g_form.setMandatory('start_date_time', true);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 06:07 AM
tried with this way also but no luck