Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Issue with Timezone conversion with day light saving .

geek_town
Kilo Expert

Hello Experts ,

We are working on a requirement where in we are converting User profile time zone to "US/Pacific" to be shown on some pages.

Packages.java.util.TimeZone.getTimeZone("US/Pacific") can convert the timezone to the time zone specified , but will it apply the day light saving also ?

Servicenow automatically applies Day light saving if the timezone mentioned Issue with the name of the place/country and not the timezone name.

As we cant ensure that every user profile timezone will be set to name   of country/places , we need to have a logic which applies the day light saving while evaluating the time in the script.

would appreciate your help on this .

Thanks in advance .

2 REPLIES 2

tim210
ServiceNow Employee
ServiceNow Employee

Hi Sandeep,



The wiki says:


For example US/Pacific is a link to the America/Los_Angeles time zone. Both America/Los_Angeles and US/Pacific represent Pacific Standard Time with the same zone offset and Daylight Savings Time (DST) schedule.


Using Time Zones - ServiceNow Wiki

So it looks like all the timezones like US/Pacific, US/Central, US/Eastern and so on will take account of daylight savings changes. The only ones that won't take account of daylight savings would be the 3-letter codes for specific timezones - PST, UTC etc. If it's possible, the best way to solve this would be to remove these from the choice list and check your User[sys_user] table to ensure no users are using these: Using Time Zones - ServiceNow Wiki



Another possibility would be to check for these 3-letter timezones in your code, but then you'd need to have a hard-coded mapping to translate them into the location-based timezones. E.g. 'PST'->'US/Pacific'.


Pranith Reddy
Kilo Contributor

Hi ,

 Did you find any logic that converts timezones including daylight saving?