- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 07:09 AM
Hi All,
Currently our instance is in PST timezone. We have created a field on Incident form and I want to set the value as follows.
<Incident created date> <8 AM EST time zone>
which means, I want to convert 8 AM EST to PST and need to place that time value in that field.
Can anyone suggest me on this. Thanks in advance.
Regards,
Ganesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 07:40 AM
Something like this might work too, depending your context (this is an example):
var est = Packages.java.util.TimeZone.getTimeZone('US/Eastern');
var pst = Packages.java.util.TimeZone.getTimeZone('US/Pacific');
var estGdt = new GlideDateTime();
estGdt.setTZ(est);
var pstGdt = new GlideDateTime();
pstGdt.setTZ(pst);
estGdt.setValue('2011-02-02 08:00:00');
gs.print('Original time: ' + estGdt);
pstGdt.setValue(estGdt);
pstGdt.addSeconds(10800); // add 3 hours
gs.print('PST time: ' + pstGdt);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 07:16 AM
Hi @Community Alums
Below is the script which can be useful for converting.
var dateTime = new GlideDateTime();
var targetTimezone = 'AST'; // provide the apt shortcut of timezone
var tz = Packages.java.util.TimeZone.getTimeZone(targetTimezone);
dateTime .setTZ(tz);
var timeZoneOffSet = dateTime .getTZOffset();
dateTime .setNumericValue(dateTime .getNumericValue() + timeZoneOffSet);
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 07:40 AM
Something like this might work too, depending your context (this is an example):
var est = Packages.java.util.TimeZone.getTimeZone('US/Eastern');
var pst = Packages.java.util.TimeZone.getTimeZone('US/Pacific');
var estGdt = new GlideDateTime();
estGdt.setTZ(est);
var pstGdt = new GlideDateTime();
pstGdt.setTZ(pst);
estGdt.setValue('2011-02-02 08:00:00');
gs.print('Original time: ' + estGdt);
pstGdt.setValue(estGdt);
pstGdt.addSeconds(10800); // add 3 hours
gs.print('PST time: ' + pstGdt);