Help with the date/time field, value not same as the value passed in service catalog form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 07:55 PM
Hi,
I am trying to pass Date/Time value from a Service Catalog. The field data type is Date/Time with Date/Time picker.
And I had a workflow, where I am passing the date/time value to a script activity in the WF.
var catdatetime = current.variables.select_date_time_gmt;
var insDate = new GlideDateTime(catdatetime);
And when I pass 2022-03-30 01:00:00 like this,
I am receiving it as 2022-03-30 06:00:00. How can I get the same value that I pass from the catalog request form?
Tried with several options but I am still seeing the diff in what was passed. Can someone shed some light on this please?
Many thanks in advance.
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:07 PM
Hi,
timezone issue
try this
var catdatetime = current.variables.select_date_time_gmt;
var insDate = new GlideDateTime();
insDate.setValue(catdatetime);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 04:37 PM
Hey Ankur,
How do I do this if I'm getting the date/time value from an Interaction and setting it in a field on an Incident?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 09:05 PM
Hi Raj,
Date/time entered in the time is in local time zone of the user who's entering it.
ServiceNow stores the time in UTC timezone so to get the same date/time as the entered value (i.e. in local timezone), it's necessary to convert as Ankur replied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2022 04:46 AM
Hi,
Thanks for the reply. Tried with several things and suggested ones also. But no luck.
Instance TZ is in PST and users are in several timezones. When I do addSeconds(-18000) it is fine.
But users are in various TZ will be using this. Wondering if this works for them or not.
Thanks