Scripting Help Convert UTC to EST

km123
Kilo Contributor

Hi,

I am in a developer instance using the full version of the Performance Analytics plugin for ServiceNow. I'm trying to edit the script for this one pre-made automated breakdown called Opened Hour Of Day, which shows the number of incidents that were opened and what hour they were opened on. The reason why I'm trying to edit this script is because while it does what it is supposed to do, the time's the breakdown is organizing it by is in UTC (ServiceNow's internal system time). The code that came already came with the breakdown is listed below:

In case you have a hard time reading the line of code it says: current.opened_at.getByFormat('H');

find_real_file.png

I would like the code to convert this output from UTC to EST please. Any help I can get would be greatly appreciated!

3 REPLIES 3

Prateek kumar
Mega Sage

Hello kim


This post might help you.


Convert UTC to Time Zone (US/Eastern) from GlideRecord query output



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

DrewW
Mega Sage
Mega Sage

I cannot think of any out of box quick methods you can just call and have this work.   You are going to have to use a regular expression to do this.   So current.opened_at.getDisplayValue() will get the date time in EST then you can use a regular expression to extract the hours.