Any Timezone to GMT timezone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 09:52 AM
The user would like the times that are entered in the Escalation Date/Time and the Probably escalation Date/Time variables to automatically convert time to GMT when they are displayed in the task. The user needs to see those times in the task that is created in the GMT time zone.
Please help me, how to update the converted time into the task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 10:25 AM
Hi,
DateTime fields are stored in UTC. So any user who has their Time zone set to GMT should see the correct value for their time zone.
Which states: "These values are stored as integer numbers, in milliseconds, and appear in the appropriate date or date/time format."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 03:36 AM
Hi Bert,
Thanks for the update.
the user wants to create a separate field and capture the time and offset to GMT in a separate field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 03:56 AM - edited 04-13-2023 03:56 AM
If you create a Date Time field SN will show it based on the user's time zone only. So you can create 2 string fields , convert into and save the time in there.
Escalation Date/Time -> User enters data in their time zone
Escalation Date/Time (GMT) -> String field, You convert the value from previous field and save here. Also make this read only.
Same for the other field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:07 AM
Hi,
the user wants to update the GMT time zone on the description of the task.
I have tried this script, but it's not working please help me with the changes
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var start = g_form.getValue('escalation_date');
var end = g_form.getValue('probably_date');
g_form.setValue('MST_start_date', toMST(start));
g_form.setValue('MST_end_date', toMST(end));
}
function toMST(start){
var time = new GlideDateTime(start);
var tz = Packages.java.util.TimeZone.getTimeZone("GMT");
time.setTZ(tz);
var timeZoneOffSet = time.getTZOffset();
time.setNumericValue(time.getNumericValue() + timeZoneOffSet);
return time;
}