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

Thanks It works.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

var gt = new GlideDateTime();


var time = gt.getDisplayValue().split(" ")[1];


gs.print(time);


SanjivMeher
Kilo Patron
Kilo Patron

Mark it answered if it worked for you to remove it from unanswered list. Let me know, if you still find any issue.



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