Background script timezone

karthik73
Mega Guru

Has there been any changes in the way timezones are handled in background scripts? Earlier i can run with my timezone (EST), but now when i try the times are being queried in UTC format.

8 REPLIES 8

Chuck Tomasi
Tera Patron

Hi Karthik,



Can you share your script with us?



Also, what release of ServiceNow are you using?


Hi Chuck, Below is the script i ran, pretty basic. the version is Eureka



var goodfriday = new GlideRecord(<tablename>);


goodfriday.addQuery ('sys_created_on','>=','2016-07-22 16:00:00');


goodfriday.addQuery ('sys_created_on','<=','2016-07-22 18:00:00');


goodfriday.addQuery ('sys_created_by','web.service');




goodfriday.query();



var count = 1;


while(goodfriday.next())



{




count = count+1;


//gs.print(goodfriday.short_description);


//gs.print(goodfriday.number);


gs.print(goodfriday.sys_created_on);


}




  1. gs.print(count);

use gs.print(goodfriday.sys_created_on.getDisplayValue());  


Abhinay Erra
Giga Sage

It depends, when you use getValue() you get in UTC and getDisplayValue() will get you in the user time zone