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 06:32 AM
but this will convert it into eastern but we are not sure like what end user timezone is ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 06:34 AM
Than better you can convert both fields into eastern timezone and compare if you are not sure on time zone. This will make it more generic.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 06:36 AM
what i am think to covert timezone in GMT and then compare . but i am not able to recall GlideDateTime in above mentioned code.
Can you please modify it in GlideDateTime()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 07:09 AM
Hi Kun,
var gDate = Packages.com.glide.glideobject.GlideDateTime(planned_start_date_time);
What value are you getting here?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 08:32 PM
This we need to use in script catalog client script or in script include?
and where we need to call this package? Can you modify above script accordingly?