- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 02:25 PM
Greetings!
I have a field in the incident table, opened_at. I would like this field to be populated with the current GMT date and time instead of the user's local time preferences.
I created a dictionary over-ride using this javascript snippet:
===> javascript:gs.nowNoTZ()
However, when I go to create a new incident record, this field is not populating correctly. I would expect it to by matching the "sys_created_on".
My local time: 2016-06-21 14:22 PDT
ServiceNow values:
<opened_at>2016-06-22 04:22:10</opened_at>
<sys_created_on>2016-06-21 21:22:34</sys_created_on>
How can I get the "opened_at" timestamp to populate as the GMT ?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 02:52 PM
The issue here is more about the display of the date and not the format of the date in the database. All dates are stored in UTC in the DB and then translated to the user's timezone on display.
So as far as default value, I would stick with gs.nowDateTime() instead of gs.nowNoTZ(), because when the record is inserted, it will take the calculated date in the default value formula and convert it to UTC, so if you use gs.nowNoTZ(), it will sort of double -convert it to UTC.
I am not sure if there is an OOTB way to display a single date field in UTC only. Checking the wiki now...
Jon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 02:52 PM
The issue here is more about the display of the date and not the format of the date in the database. All dates are stored in UTC in the DB and then translated to the user's timezone on display.
So as far as default value, I would stick with gs.nowDateTime() instead of gs.nowNoTZ(), because when the record is inserted, it will take the calculated date in the default value formula and convert it to UTC, so if you use gs.nowNoTZ(), it will sort of double -convert it to UTC.
I am not sure if there is an OOTB way to display a single date field in UTC only. Checking the wiki now...
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 05:25 PM
Thanks - I checked it out and your explanation makes perfect sense. There's no need for it to display UTC only at all times. As long as it's store in the database as UTC, I can fetch that value.
Cheers!