Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Getting time based on user time zone in scoped application

Eli Guttman
Tera Guru

Hi,

 

We are looking for a way to get a certain date and time in specific time zone using a script. While there are few methods available in the global application, we can't find any in a scoped application.

For example, the setTimeZone function is not available in scoped application:

 

 

var mytime = new GlideDateTime();
mytime.setTimeZone(user.time_zone);

 

 

Is there any parallel option in scoped application?

7 REPLIES 7

Shruti
Giga Sage

Hi,

There is no parallel option in scoped application but you can create a script include in global scope and try below code

Shruti_0-1706098967211.png

 

Thank you, this is the only solution i found also. It does require to handle some caller restricted access records when you use the script from different scope.

vermaamit16
Kilo Patron

Hi @Eli Guttman 

 

You can use setTimeZone as below in a scoped application :

 

var now = new GlideDateTime();
gs.info("System Time is " + now);
var gsdt = new GlideScheduleDateTime(now);
gsdt.setTimeZone("Europe/London");
gs.info("London time is " + gsdt.getGlideDateTime().getDisplayValue());

 

Thanks & Regards

Amit Verma

Thanks and Regards
Amit Verma

Hi, this solution did not work for me. 

+ gsdt.getGlideDateTime().getDisplayValue()

 

Do not return the expected time according to the time zone i set.