How to get current logged in user time zone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:05 AM
HI All,
I my email notification i need to print current logged in user time zone . But it is picking system time zone. i have tried the below codes but still no luck..
Could any one suggest how can we get logged in user time zone????????
var tz = gs.getUser();
var x = tz.getTZ();
gs.print(x); //O/P : US/Pacific-New
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:43 AM
Hi,
What does logged in user mean here?
because email notification might trigger with system or in some user's session.
What is your case?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2020 08:34 AM
This resolved my issue. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:09 AM
you can also try
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
gs.print(gr.time_zone);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:09 AM
try below
var gus = gs.getUser();
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',gus);
gr.query();
if(gr.next())
{
gs.print('Therefore user is in this timezone'+gr.time_zone);
}
Mark my ANSWER as CORRECT and HELPFUL if it helped.