Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Things to know when using GlideDateTime object within flow action script and passing this object as an output variable - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Things to know when using GlideDateTime object within flow action script and passing this object as an output variable
KB0812370

Things to know when using GlideDateTime object within flow action script and passing this object as an output variable


5466 Views Last updated : Apr 8, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Inside a flow action if there is a script which stores GlideDateTime object in a local variable and when this variable is passed as an output  variable of type String or Date/Time, after the flow execution, the date/time displayed on flow execution details page is in different format. ie. It displays date/time in User's timezone instead of UTC [internal format].

Example: There is a flow action with following code in the script section:

(function execute(inputs, outputs) {
// ... code ...
var current_datetime = new GlideDateTime();
outputs.current_datetime = current_datetime; 
outputs.current_datetime_in_datetime = current_datetime; 
gs.log("*** GlideDateTime object *** " + current_datetime);
})(inputs, outputs);

where 'current_datetime' is an output variable of type 'String' and 'current_datetime_in_datetime' is an output variable of type 'Date/Time'

After the flow execution, the date/time displayed in

System log will be : *** GlideDateTime object *** 2020-01-22 01:53:30 // in UTC 

On flow execution details page the output variables will be :

current_datetime 21-01-2020 17:53:30 // in User's timezone
current_datetime_in_datetime 21-01-2020 17:53:30 // in User's timezone

Cause

On Flow execution details page, date/time will be displayed using the value from GlideDateTime.getDisplayValue() which displays date/time in User's timezone.

Resolution

On Flow execution details page, if you want date/time to be displayed in UTC, then inside the script use the value from GlideDateTime.getValue() method.

ie. Change the script to 

(function execute(inputs, outputs) {
// ... code ...
var current_datetime = new GlideDateTime();
outputs.current_datetime = current_datetime.getValue(); 
outputs.current_datetime_in_datetime = current_datetime.getValue(); 
gs.log("*** GlideDateTime object *** " + current_datetime);
})(inputs, outputs);

After the flow execution, the date displayed in

System log will be : *** GlideDateTime object *** 2020-01-22 01:53:30 // in UTC 

On flow execution details page the output variables will be :

current_datetime 2020-01-22 01:53:30 // in UTC
current_datetime_in_datetime 2020-01-22 01:53:30 // in UTC

 

Related Links

To learn more about GlideDateTime API and its methods, refer below documentation link

https://docs.servicenow.com/csh?topicname=c_GlideDateTimeAPI.html&version=latest


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.