How to display the date and time of another region in an email script

Mario Preciado
Tera Contributor

Hi Community.

 

How to display the date and time of a different region in an email script if my ServiceNow server is set to the default U.S. timezone.

1 ACCEPTED SOLUTION

You can pass current.variables.hora_check_inn (assuming it's a date/time value) into the script I provided

var dateVal = new GlideDateTime(current.variables.hora_check_inn);
var pacificTime = new ScheduleDateTime(dateVal).convertTimeZone(gs.getSysTimeZone(), 'US/Pacific');
gs.info(pacificTime)

 

View solution in original post

4 REPLIES 4

Kieran Anson
Kilo Patron

Hi Mario,

Try the below. 

var now = new GlideDateTime();
var pacificTime = new GlideScheduleDateTime(now).convertTimeZone(gs.getSysTimeZone(), 'US/Pacific');
gs.info(pacificTime)

Alternatively, you can use the provided script include 'ScheduleDateTime' which does the same as the above.

var now = new GlideDateTime();
var pacificTime = new ScheduleDateTime(now).convertTimeZone(gs.getSysTimeZone(), 'US/Pacific');
gs.info(pacificTime)

I am returning the variable that contains the date and time using the following code: template.print('<label><b>' + current.variables.hora_check_inn.getDisplayValue() + '</b></label>');. The last thing I tried was applying getDisplayValue().

You can pass current.variables.hora_check_inn (assuming it's a date/time value) into the script I provided

var dateVal = new GlideDateTime(current.variables.hora_check_inn);
var pacificTime = new ScheduleDateTime(dateVal).convertTimeZone(gs.getSysTimeZone(), 'US/Pacific');
gs.info(pacificTime)

 

It worked very well.