Time zone e-mail script

Matheus Rissi2
Tera Expert

Hello everyone

I currently have the following script to change the date format in my email:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
	
	var date = new GlideDateTime(current.parent_incident.sys_created_on);
	template.print(date);

})(current, template, email, email_action, event);

 

But he is using the GMT time zone. I need to use America/Sao_Paulo.
Can you help me?
Thanks

4 REPLIES 4

Ankita19
Tera Guru
Tera Guru

Check this :

https://community.servicenow.com/community?id=community_question&sys_id=2adfc3a5dbdcdbc01dcaf3231f9619f2

 

https://community.servicenow.com/community?id=community_question&sys_id=789e7665db58dbc01dcaf3231f961960

Community Alums
Not applicable

Hello,

-----------------------------------------------------------------------------------------

The setValue() and getValue() methods require parameters in the UTC time zone and internal format. Other formats may return invalid results.

The toString() method returns the same string as the getValue() method.

The setDisplayValue() and getDisplayValue() methods require parameters in the local time zone (user/system) and local format (user/system). Other formats may return invalid results.

//Example: If user’s date time format is MM.dd.yyyy HH:mm:ss

// Do this

var input = “08.05.2015 16:21:47”;
var gdt = new GlideDateTime();
gdt.setDisplayValue(input);

// Not this

var input = “08.05.2015 16:21:47”;
var gdt = new GlideDateTime(input);

 

-----------------------------------------------------------------------------------------

So in your case try to use 

var gdt = new GlideDateTime();
gdt.setDisplayValue(current.parent_incident.sys_created_on);
template.print(gdt);

 

 

Regards,

Akshay

Community Alums
Not applicable

Hi Matheus Rissi,

Didn't hear back on this.

Is your issue resolved? If yes, feel free to mark helpful/correct, so it will be helpful for others looking for similar query.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you saying irrespective of whatever timezone the recipient is the date/time value should always show value in America/Sao_Paulo timezone?

Can you share your exact requirement?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader