How to remove GMT after date & time on notification

Nagarjuna Redd2
Tera Contributor

Hi All,

i have two "Date/Time" fields (EST time) on Catalog Item. when i try to call those variables on Notification Through Email script the format is as below

Start Date/Time: 2019-12-25 06:59:29 GMT

End Date/Time: 2019-12-26 06:59:31 GMT

here time time represents EST time but it is showing as GMT as servicenow having default GMT timezone.

can any one suggest how can i achieve 2019-12-25 06:59:29 EST instead of 2019-12-25 06:59:29 GMT.

Thanks,

Nagarjuna

6 REPLIES 6

Harsh Vardhan
Giga Patron

you can use setTZ().

 

eg:

 

var tz = gs.getSession().getTimeZone();
var gdt = new GlideDateTime(<fetch field value>); 
gdt.setTZ(tz);

Manas Kandekar
Kilo Guru

Hello

 

if(v.getGlideObject().getQuestion().getLabel() == '<field1_display_name>' && v.getDisplayValue() != '')
{

var date1 = v.getDisplayValue();

date1 = str.replace("GMT""EST");

template.print('Start Date/Time: ' + date1  + '<br/>');
}

if(v.getGlideObject().getQuestion().getLabel() == '<field2_display_name>' && v.getDisplayValue() != '') 
{

var date2 = v.getDisplayValue();

date2 = str.replace("GMT""EST");

template.print('End Date/Time: ' + date2  + '<br/>');
}

Nagarjuna Redd2
Tera Contributor

Thanks for reply.

How can i proceed in the below case.

 

i have some other fields also to bring into notification along with those two fields.

please suggest.

find_real_file.png

find_real_file.png

Hi,

template.print will actually print whatever you want to show.

If you want to add other fields, query them (if you need to get from DB), and simply add them by using template.print(gr.field_name) //something like this.

Mark the comment as a correct answer and helpful if this helps.