- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 09:40 AM
I am developing a Flow Designer flow with a "Wait for Condition" action that has a timeout. The timeout value should be the relative time between a catalog variable "due_date" and the current date/time. I am in the US/Central timezone (UTC-5 currently). When my script retrieves the "due_date" it come back in UTC time, but when I retrieve the current date/time it retrieves the time in my current timezone. The result is that my relative time interval in the "Wait for condition" timeout value is off by 5 hours.
How can I compare a variable in UTC time with my current time in US/Central? I can't figure out how to get both values in the same timezone value to compare them properly.
Thanks for any guidance!
Joe
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 07:10 PM
Hi @Joe Trimble ,
You can use below script to convert the UTC time into US/Central time.
var time = new GlideDateTime();
gs.info('UCT Time ' + time);
var targetTimezone = 'CST'; // ensure you give correct timezone Abbreviation
var tz = Packages.java.util.TimeZone.getTimeZone(targetTimezone);
time.setTZ(tz);
var timeZoneOffSet = time.getTZOffset();
time.setNumericValue(time.getNumericValue() + timeZoneOffSet);
gs.info('CST' + time);
For more information you can refer below below community blog.
https://www.servicenow.com/community/developer-blog/convert-timezone/ba-p/2287262.
If my answer solved your concern please mark it as Helpful 👍 and Accepted ✔️.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 07:10 PM
Hi @Joe Trimble ,
You can use below script to convert the UTC time into US/Central time.
var time = new GlideDateTime();
gs.info('UCT Time ' + time);
var targetTimezone = 'CST'; // ensure you give correct timezone Abbreviation
var tz = Packages.java.util.TimeZone.getTimeZone(targetTimezone);
time.setTZ(tz);
var timeZoneOffSet = time.getTZOffset();
time.setNumericValue(time.getNumericValue() + timeZoneOffSet);
gs.info('CST' + time);
For more information you can refer below below community blog.
https://www.servicenow.com/community/developer-blog/convert-timezone/ba-p/2287262.
If my answer solved your concern please mark it as Helpful 👍 and Accepted ✔️.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 09:02 AM
Thanks, Vrushali. This is very helpful.