Help with the date/time field, value not same as the value passed in service catalog form.

Raj76
Tera Contributor

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 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

timezone issue

try this

var catdatetime = current.variables.select_date_time_gmt;
var insDate = new GlideDateTime();
insDate.setValue(catdatetime);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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?

Hitoshi Ozawa
Giga Sage
Giga Sage

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.

Raj76
Tera Contributor

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