How to convert string to US/Eastern TimeZone
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 05:31 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 05:36 AM
Yata,
Here is a sample of the script that convert time to UTC timezone :
- // Get date from service now
- var time = new GlideDateTime(current.u_start_date);
- // Display date retrieved
- gs.print('GMT Time: '+time);
- // Set timezone
- var tz = Packages.java.util.TimeZone.getTimeZone("America/New_York");
- time.setTZ(tz);
- // Get offset of timezone set above
- var timeZoneOffSet = time.getTZOffset();
- // Add offset to current time
- time.setNumericValue(time.getNumericValue() + timeZoneOffSet);
- // Print date/time in desired timezone
- 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