- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 03:52 PM
Can anyone help me with the script to get the time in the user's timezone?
var gt = new GlideDateTime();
var gdt = gr.getTime();
gs.print(gdt.getDisplayValue());
The script above is displaying with an error of (-1) hour.
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 04:07 PM
Use below if you just need time
var gt = new GlideDateTime();
gs.print(gt.getDisplayValue().split(' ')[1]);
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 03:54 PM
Use getLocalDate();
var gdt = new GlideDateTime("2011-08-31 08:00:00");
gs.print(gdt.getLocalDate());
http://wiki.servicenow.com/index.php?title=GlideDateTime#getLocalDate.28.29
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 03:56 PM
Thank you for the reply.
But I need the time?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 03:59 PM
var gdt = new GlideDateTime("2011-08-31 08:00:00");
gs.print(gdt.getLocalTime());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 04:02 PM
It shows some junk value I believe.
var gdt = new GlideDateTime(gs.nowDateTime());
gs.print(gdt.getLocalTime());
1970-01-01 01:01:54
var gdt = new GlideDateTime("2011-08-31 08:00:00");
gs.print(gdt.getLocalTime());
1970-01-01 03:00:00