Flow Designer script action date handling issue

Erik Gunther2
Kilo Guru

I don't understand how Flow Designer processes dates and times. I created a simple Script Action to test inputs and outputs. The first screenshot shows the script action. It's a very simple pass through of the date/time value as a date/time and as a string. The second screenshot shows that whatever date/time value you pass in as the date_time parameter, you get a date/time value that is shifted by several hours (or more depending on the various methods I've tried).

find_real_file.png

find_real_file.png

And finally, I ran some background scripts to see if I had a time zone discrepancy, which I don't think I do.

find_real_file.png

find_real_file.png

Please explain why the date shifts in the Script Action. And more importantly, what approach do I use so that I can copy the value without changing the time?

Thanks.

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Erik,

new GlideDateTime() would always give you GMT time

see in background script below

gs.info(new GlideDateTime()); // this will give GMT time

gs.info(new GlideDateTime().getDisplayValue()); // this will give your local time

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Erik,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement & close the thread. Thanks in advance.

Regards
Ankur

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

I marked your response as helpful because it clarified for me that the GlideDateTime default value is in GMT format. But I think there's a bug in Flow Designer with dates. I submitted a HI ticket and will update here when I learn more. I see 2 issues in flow designer:

  • The Date Time value passed into the Script Action is 1 hour less than GMT
  • getDisplayValue does not return the local time but the same 1 hour less time

I implemented a workaround but want to find out if there's a bug in Flow or if there's still something I don't understand about how this process is supposed to work.

Sure Erik

Do let us know the update from ServiceNow

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