GlideDateTime Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 11:33 AM - edited 06-02-2023 11:36 AM
Hi Developers,
I am curious as to why one method works and the other one doesn't. I have a script that is being triggered from a UI action to populate date/time field when it is triggered.
This script is giving me the GMT time on the field which is not what I'm looking for.
var currentTime = new GlideDateTime();
current.variables.abc = currentTime.getDisplayValue();
This line below is giving me the result I want, which is seeing the field in my timezone.
current.variables.abc = new GlideDateTime();
I am not sure why both are producing different results. Please help me clarify.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 11:43 AM - edited 06-02-2023 11:46 AM
Hi @zynsn
The below is how ServiceNow built the GlideDateTime Class
gs.print(new GlideDateTime()); //Gives Time in UTC
Outpot - 2023-06-02 18:40:44
gs.print(new GlideDateTime().getDisplayValue()); //gives time in User's profile time zone which in this case is US/Central
Output - 2023-06-02 13:40:44
User's selected Time zone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 11:50 AM