Want to convert GMT to EST/PST by passing timezone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2021 04:49 AM
Want to convert GMT to EST/PST by passing timezone. Can you please help me how can we do that in service now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 01:27 AM
Hi Ankur, thanks for the reply but can i pass "America/newyork and get the output as EST?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 01:45 AM
Hi,
I tried giving that timezone name. It didn't work you can simply use EST
EST -> means America (NewYork) only
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 10:29 PM
you can try this
var gdt = new GlideDateTime();
var gdt1 = new GlideDateTime();
var timezone = "EST";
var tz = Packages.java.util.TimeZone.getTimeZone(timezone );
gdt1.setTZ(tz);
gdt1.setValue(gdt); //in place of gdt, you can mention your date/time object variable
start = new GlideDateTime(gdt1.getDisplayValue()); //returns the date/time in EST in date/time object
var fdate = start.getDate().getByFormat('YYYY-MM-dd') + " " + start.getTime().getByFormat('hh:mm a')+" "+timezone ;
gs.print(fdate );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 01:26 AM
Hi Pramesh, thanks for the reply but can i pass "America/newyork and get the output as EST.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 01:34 AM
yes you can
var gdt = new GlideDateTime();
var gdt1 = new GlideDateTime();
var timezone = "EST";
var tz = Packages.java.util.TimeZone.getTimeZone('America/newyork' );
gdt1.setTZ(tz);
gdt1.setValue(gdt); //in place of gdt, you can mention your date/time object variable
start = new GlideDateTime(gdt1.getDisplayValue()); //returns the date/time in EST in date/time object
var fdate = start.getDate().getByFormat('YYYY-MM-dd') + " " + start.getTime().getByFormat('hh:mm a')+" "+timezone ;
gs.print(fdate );