How to convert string to US/Eastern TimeZone

niharikayb
Kilo Contributor

Hi,

Is there any script for converting string value to EST timezone?

We have source Field coming as string value say "1899-12-31 02:03:00"

It should be converted to time field(target) in EST .

Please Suggest.

Thanks in Advance

1 REPLY 1

zica
Giga Guru

Yata,



Here is a sample of the script that convert time to UTC timezone :


  1.   // Get date from service now  
  2.       var time = new GlideDateTime(current.u_start_date);  
  3.       // Display date retrieved  
  4.       gs.print('GMT Time: '+time);  
  5.       // Set timezone  
  6.       var tz = Packages.java.util.TimeZone.getTimeZone("America/New_York");  
  7.       time.setTZ(tz);  
  8.       // Get offset of timezone set above  
  9.       var timeZoneOffSet = time.getTZOffset();  
  10.       // Add offset to current time  
  11.       time.setNumericValue(time.getNumericValue() + timeZoneOffSet);  
  12.       // Print date/time in desired timezone  
  13.       gs.print('Eastern time: '+time);  


Also I found a thread on the community that coud help you out to achieve your query   :


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