In transform map need to convert UTC to EST time

sanju41
Giga Contributor

How to convert UTC Time to EST time?

  1. function getLocalDate() {  
  2.   var gdt = new GlideDateTime(); // Without input sets it to current UTC.  
  3.   //gs.log(gdt); *** Script: 2015-02-28 02:08:41 (UTC).  
  4.   var timeZoneOffSet = gdt.getTZOffset();  
  5.   //gs.log(timeZoneOffSet); *** Script: -18000000 (milliseconds). -5 Hours offset (EST)  
  6.   gdt.setNumericValue(gdt.getNumericValue() + timeZoneOffSet);   //EST
  7.   return gdt;  
  8. }  

This code will use current UTC time and convert to EST.

I need a input to set for UTC (dynamic input ) expecting output as EST

2 REPLIES 2

Chuck Tomasi
Tera Patron

Hi Sankeerth,



Just pass your date/time as a parameter to new GlideDateTime().



See section 3.2 here.



GlideDateTime - ServiceNow Wiki


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee