
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 04:47 AM
Hi All,
How do I get timezone offset and day light saving applicable?(true or false) for opened for user timezone.
We have requiremnt in which we need to populate this values in notification.
currently I could only get user time zone by doing dot walking in opened for field.
Any input on this would be much appreciated 🙂
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 06:50 AM
Try that:
var openedFor = gs.getUser().getUserByID('opened_for');
var tz = Packages.java.util.TimeZone.getTimeZone(openedFor.getTZ()); //set time zone based on user record
var time = new GlideDateTime(); //utc
time.setTZ(tz); //set time based on tz variable
var timeZoneOffSet = time.getTZOffset(); // calculate offset from utc
time.setNumericValue(time.getNumericValue() + timeZoneOffSet);
gs.print('the time you're looking for: ' + time)
Regarding Daylight Saving Time it depends what value is set on sys_user table:
"In general, if a time zone is specified based on location (for example, America/Los Angeles), the system automatically adjusts for daylight saving time. If a time zone is specified based on the name of a time zone (for example, GMT), which is discouraged, it does not typically adjust for daylight saving time."
https://docs.servicenow.com/bundle/istanbul-platform-administration/page/administer/time/reference/r_TimeZones.html

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 05:03 AM
You can use TimeZone Offset which converts the time in Milli Seconds after your validation you can the convert to actual time zone:
Example
var dates = this.getParameter('sysparm_dates');
var now = new GlideDate();
//gs.addInfoMessage("current date" +now);
now.addDays(6);
var nowtz = now.getTZOffset();
gs.addInfoMessage("Now time converted into milli seconds using timezone offset" + nowtz);
now.setNumericValue(now.getNumericValue() + nowtz);
gs.addInfoMessage(now);
https://docs.servicenow.com/bundle/london-platform-administration/page/administer/time/reference/r_TimeZones.html
Please Mark it as Helpful / Correct based on the impact.
Abdul Azeez

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 05:17 AM
thanks for your reply 🙂
I am working on email client template-which will be sent by managers.the notifcation contains fields like,
opened for, user-time zone offset,is user timezone daylightsaving applicable?
I have created a email script for this.
for daylight saving--
var gdt = new GlideDateTime();//it takes the manger csystem date not the opened for timezone
template.print(gdt.isDST());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 05:09 AM
Hi,
Please go to the following article which can help you out,
https://community.servicenow.com/community?id=community_article&sys_id=93243904dbf7e700feb1a851ca961961
Regards,
Munender

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 05:19 AM
Thanks for your reply 🙂
I am working on email client template-which will be sent by managers.the notifcation contains fields like,
opened for, user-time zone offset,is user timezone daylightsaving applicable?
I have created a email script for this.
for daylight saving--
var gdt = new GlideDateTime();//it takes the manger csystem date not the opened for timezone
template.print(gdt.isDST());