Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get current logged in user time zone?

sinu2
Tera Expert

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

 

 

 

 

 

 

9 REPLIES 9

Mike Patel
Tera Sage

you can try

var session = gs.getSession();
var zoneName = session.getTimeZoneName();
gs.print(zoneName);

Hi Patel,

 

Thanks for the reply. I have kept your code in my email script but still it is taking the system ID not logged in user ID.

 

But if i run the same script in my background script it is taking loggedin user ID

Elijah Aromola
Mega Sage

Try the following: 

var session = gs.getSession();
var zoneName = session.getTimeZoneName();
gs.print(zoneName);

Please mark this as correct/helpful if it resolved your issue!

Hi ,

 

Thanks for the reply. I have kept your code in my email script but still it is taking the system ID not logged in user ID.

 

But if i run the same script in my background script it is taking loggedin user ID