how to know user time zone from script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 02:46 AM
Hi,
I have the date field in my catalog item and auto populate default date something, i have done that, but the issue is, it is showing different because of user based on user time zone.
so, for that i need to write script to validate whether the user time zone is universal if not how to check the user time zone.
example ; i am in universal time zone but my colleague in japan i need to add utc + 9hrs how to write the script please suggest.
thanks
venkatesh t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 03:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 03:09 AM
hI @t venkatesh1 ,
There is a field Called Time zone in user table which hold the timezone of that user so you can try adding the below code in your script.
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
gs.info('Time Zone '+ gr.time_zone);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 03:19 AM - edited 05-20-2024 03:20 AM
Thanks for the quick response, i am not sure it will works in script include.
i want to check two situations one is if user time zone = universal(default date is showing correct) or else user time zone is Japan(one day back date it is showing) need to add utc +9. in this two scenarios how to define the script to validate the user time zone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 11:53 AM
This should work in script include because if you check in your system property -> Basic configuration there the timezone will be set for user so, same will be captured in sys_user table Time zone field so based on your condition you can use it in your script include,
let me know if you need help with the coding and please share whatever you tried or you have configured?
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang