- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
In ServiceNow, g_form.getValue() returns the user’s display value for a Date/Time field. How can I retrieve the actual system (UTC) value of that field inside a Script Include?”
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
When you pass a display value into your Script Include, you should wrap it in a GlideDateTime object. Set that object’s display value to the one you received from the GlideAjax call.
Once the display value is set, you can safely use the server value (.getValue()
) from the GlideDateTime object, which will return the UTC time.
This approach removes the need for manual conversions or lengthy scripts—the platform handles the conversion for you.
Using .getValue() would get you the server value, which is stored in UTC.
Using .getDisplayValue() would get you the display value of the field, which is set to your preference and timezone.
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
When you pass a display value into your Script Include, you should wrap it in a GlideDateTime object. Set that object’s display value to the one you received from the GlideAjax call.
Once the display value is set, you can safely use the server value (.getValue()
) from the GlideDateTime object, which will return the UTC time.
This approach removes the need for manual conversions or lengthy scripts—the platform handles the conversion for you.
Using .getValue() would get you the server value, which is stored in UTC.
Using .getDisplayValue() would get you the display value of the field, which is set to your preference and timezone.
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/