How to Print Timezone in Email Scripts

Arun91
Tera Contributor

Hi,

 

I using policy exception we have a field called expiration date. I have created email notifications in task table when the task is created. In task email notification I have to print expiration date along with timezone. I have created email scripts already but it is not updating the Timezone

 

could you please help me on this.

3 REPLIES 3

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Arun91 ,

 

var gr = new GlideRecord('sys_user');
if(gr.get(gs.getUserID()){
var getTZ_time = getUserTime(gs.nowDateTime(), gr.time_zone);
template.print(getTZ_time + ' ' + userGR.time_zone + ' - ' + userGR.name);
//other code....
}

function getUserTime(date,usertimezone){
var timezone = Packages.java.util.TimeZone.getTimeZone(usertimezone);
var gdt = new GlideDateTime(date);
gdt.setTZ(timezone);
gdt.setNumericValue(gdt.getNumericValue() + gdt.getTZOffset());		
return gdt;
}

 

Above code can help... 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

We are not using timezone in user profile and date expiration is date and time field. How we can achieve this.

then how do you determine the timezone of your exp date ?


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect