How to get current date time in user logged in time zone - client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2022 10:51 PM
Hello,
I am using var nowTime = new Date().getTime(); to get the current date time, but this is not returning in logged is user timezone.
Can anyone please let me know how to get urrent date time in user logged in time zone in client scripts
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2022 10:58 PM
Check this out
https://community.servicenow.com/community?id=community_question&sys_id=38c40be9dbd8dbc01dcaf3231f9619e3

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2022 11:45 PM
Hi dharani2607,
Ankur's reply is correct. "new GlideDateTime()" will get the date/time in UTC. .getDisplayValue() will return the date/time in current's user's date format and timezone.
var gdt = new GlideDateTime();
gs.info(gdt.getDisplayValue());
getDisplayValue()
To get the date/time is yyyy-MM-dd HH:mm:ss format but in the current user's time format, use getDisplayValueInternal().