Glide date/time

Niharika14
Tera Contributor

Hi All,

 

I have one doubt i.e when we create an object of glide date time , it return time in which timezone ,UTC or system timezone.

For eg . var gdt= new GlideDateTime();
              current.fieldname=gdt;

This will populate the field in which timezone , system's timezone?

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

Please go through this support article to clear your doubts about instance timezone. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0714577. An instance timezone can be set using the property glide.sys.default.tz. If this value is not set, it usually picks the timezone of Java Virtual Machine (JVM). This timezone value is used for the display purposes, the actual date time is stored in UTC format in database tables. 

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

Please go through this support article to clear your doubts about instance timezone. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0714577. An instance timezone can be set using the property glide.sys.default.tz. If this value is not set, it usually picks the timezone of Java Virtual Machine (JVM). This timezone value is used for the display purposes, the actual date time is stored in UTC format in database tables. 

Thanks for the reply. This article is very useful , cleared all my doubts but have one last doubt . The timezone that can be seen on general table in settings (gear) of instance is system timezone only right?

Niharika14_0-1680089198838.png

 

The timezone which you see in the user preference is user's own preference for the timezone. It represents timezone for the logged in user and not the instance. Any changes here will change logged in user's timezone in preference and not the instance's timezone. 

Screenshot 2023-03-29 at 6.07.00 PM.png

 

However, if you need to set instance timezone, the you can do it via the basic configuration.

Screenshot 2023-03-29 at 6.19.40 PM.png

To change this value, follow these steps:

  1. Log in to the instance using an admin account
  2. Navigate to: System Properties > Basic Configuration
  3. Scroll to the System timezone for all users unless overridden in the user's record heading
  4. From the pull-down menu, select the appropriate timezone value you would like to set as the default for the instance (i.e. US/Pacific).
    • If you notice that the current value is "System", this indicates that the time zone is the default time zone from the server.
  5. Save

Reference: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0714577

Adrian Ubeda
Mega Sage
Mega Sage

Hi Niharika14, 

Here's the description of that scoped method in developer documentation: https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server/no-namespace/c_APIRef#r_ScopedG...

 

GlideDateTime stores date/time using UTC Standard date/time to be neutral, not uses the session timezone. For that you new to use something similar as follows:
var session = gs.getSession();
var zoneName = session.getTimeZoneName();
 
If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆