- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 03:39 AM
I am using glidedatetime function and getting the date/time....it is coming in gmt timezone,but i need in ist.
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 04:16 AM
you can do it like this.
//assuming start is the date/time object as per above code
var st_date = start.getDate();
var st_time = start.getTime();
var start_date = st_time.getByFormat("HH:mm") +" "+ st_date.getByFormat("dd MMMM YYYY");
gs.print(start_date);
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 03:43 AM
Hi,
Try this code.
var gdt = new GlideDateTime();
var gdt1 = new GlideDateTime();
//sets to IST
var tz = Packages.java.util.TimeZone.getTimeZone("IST");
gdt1.setTZ(tz);
gdt1.setValue(gdt); //in place of gdt, you can mention your date/time object variable
var start =gdt1.getDisplayValue(); //returns the date/time in IST timezone as a string.
start = new GlideDateTime(start); //returns the date/time in IST in date/time object
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 04:09 AM
and also how can i format the date an time in this manner : (HH:ss) (DD-MM-YYYY)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 04:16 AM
you can do it like this.
//assuming start is the date/time object as per above code
var st_date = start.getDate();
var st_time = start.getTime();
var start_date = st_time.getByFormat("HH:mm") +" "+ st_date.getByFormat("dd MMMM YYYY");
gs.print(start_date);
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 03:44 AM
Hey dell,
Here is a same thread that you looking for it will help you:
Or
Try this out:
setTZ(TimeZone timeZone)
Sets the time zone of the GlideDateTime object to be the specified time zone.
var tz = gs.getSession().getTimeZone();
var gdt = new GlideDateTime();
gdt.setTZ(tz);
Kindly Mark Correct if this solves your issue and also mark Helpful if you find my response worthy!
Best Regards,
Namrata