- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 09:34 PM
How can i convert UTC to CST? below is my code.please let me know what i am missing here
validateDay: function() {
var Date = this.getParameter('sysparm_user_name');
var gdt = new GlideDateTime(Date);
var currDate = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("CST");
currDate.setTZ(tz);
var timeZoneOffSet = currDate.getTZOffset();
gs.log('Convert: '+timeZoneOffSet);
var diff = gs.dateDiff(timeZoneOffSet ,Date,true);
if ((Date > timeZoneOffSet) && (diff/3600 > 48))
{
return true;
} else {
return false;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 11:27 PM
Following will convert entered UTC date/time to CST
Script Include:
var convertDateTime = Class.create();
convertDateTime.prototype = Object.extendsObject(AbstractAjaxProcessor, {
convertDateTime: function() {
var parmDate = this.getParameter('sysparam_datetime');
var gdt = new GlideDateTime(parmDate);
var tz = Packages.java.util.TimeZone.getTimeZone("America/Chicago");
gdt.setTZ(tz);
return gdt.getDisplayValue();
},
type: 'convertDateTime'
});
Catalog Client Scripts
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('convertDateTime');
ga.addParam('sysparm_name', 'convertDateTime');
ga.addParam('sysparam_datetime', g_form.getValue('u_date'));
ga.getXMLAnswer(function(answer) {
g_form.setValue("CST", answer);
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 09:41 PM
What is it you want to do and how do you set the value for sysparm_user_name (and why is that a date)?
It looks like at the end you do a comparison to see if the difference is bigger then 48h?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 09:44 PM
Hey Sraj,
Refer the threads below, it might help you:
Mark it Correct or Helpful, if it works based on impact....!!!!
Best Regards,
Namrata.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 09:44 PM
Hi Sraj
I n Addition to Namrata Refer the Links...This Might Help You
How to convert GMT date to EST
how to convert glideDateTime that from GMT to EST using script include
In transform map need to convert UTC to EST time
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 11:27 PM
Following will convert entered UTC date/time to CST
Script Include:
var convertDateTime = Class.create();
convertDateTime.prototype = Object.extendsObject(AbstractAjaxProcessor, {
convertDateTime: function() {
var parmDate = this.getParameter('sysparam_datetime');
var gdt = new GlideDateTime(parmDate);
var tz = Packages.java.util.TimeZone.getTimeZone("America/Chicago");
gdt.setTZ(tz);
return gdt.getDisplayValue();
},
type: 'convertDateTime'
});
Catalog Client Scripts
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('convertDateTime');
ga.addParam('sysparm_name', 'convertDateTime');
ga.addParam('sysparam_datetime', g_form.getValue('u_date'));
ga.getXMLAnswer(function(answer) {
g_form.setValue("CST", answer);
});
}