The CreatorCon Call for Content is officially open! Get started here.

Current time in user's timezone

snowtech1
Tera Expert

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.

1 ACCEPTED SOLUTION

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.

View solution in original post

12 REPLIES 12

Below should work



var gt = new GlideDateTime();


gs.print(gt.getDisplayValue());



Please mark this response as correct or helpful if it assisted you with your question.

Yes it displays the date and time. Think I will have to parse out the time from it.


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.

It there a recommended way to include AM/PM on the split?


Currently it includes only the time, I'm using it on a time field and need am/pm


var gt = new GlideDateTime();


var time = gt.getDisplayValue().split('')[2];



The one above gives AM/PM