function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken Koellner 1Ken Koellner 1 

Get longer timezone description

Under personnal preference, you see timezone Names like --

Line Is. Time (Pacific/Kiritimati)
Phoenix Is.Time (Pacific/Enderbury)
Tonga Time (Pacific/Tongatapu)
...
Eastern Daylight Time (America/Indiana/Indianapolis)
Eastern Daylight Time (America/New_York)

But User.TimeZoneSidKey has only the ISO timezone name like "America/New_York".

Is there any place in SF where Apex code can get the fullname like like "Eastern Daylight Time (America/New_York)"?
 
Dmitry OfitserovDmitry Ofitserov
Hi Ken,
Try running the following code (in developer console) and see if it helps:
String userTimeZone = UserInfo.getTimeZone().getDisplayName() + ' (' + UserInfo.getTimeZone().toString() + ')';
System.debug(userTimeZone);

 
Ken Koellner 1Ken Koellner 1
Dimitry, thanks for the suggestion but that is a couple issue.  First, I want to put together a picklist so I'd have to do something like that for the full list of time zones.  Second, SF may actually returns incorrect (or at least confusing) information; a problem I noticed a year or two ago.

I'm in America/New_York and when I run that today, it get --

 
10:07:24.1 (1021356)|USER_INFO|[EXTERNAL]|005460000010bMf|kkoellner@catdev.com|Eastern Standard Time|GMT-04:00
10:07:24.1 (1042530)|EXECUTION_STARTED
10:07:24.1 (1046768)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
10:07:24.1 (1566671)|SYSTEM_METHOD_ENTRY|[1]|UserInfo.UserInfo()
10:07:24.1 (1581669)|SYSTEM_METHOD_EXIT|[1]|UserInfo
10:07:24.1 (1621888)|METHOD_ENTRY|[1]||System.UserInfo.getTimeZone()
10:07:24.1 (1879882)|METHOD_EXIT|[1]||System.UserInfo.getTimeZone()
10:07:24.1 (1932746)|METHOD_ENTRY|[1]||System.TimeZone.getDisplayName()
10:07:24.1 (1959016)|METHOD_EXIT|[1]||System.TimeZone.getDisplayName()
10:07:24.1 (1985967)|METHOD_ENTRY|[1]||System.UserInfo.getTimeZone()
10:07:24.1 (2029465)|METHOD_EXIT|[1]||System.UserInfo.getTimeZone()
10:07:24.1 (2059342)|METHOD_ENTRY|[1]||System.TimeZone.toString()
10:07:24.1 (2095174)|METHOD_EXIT|[1]||System.TimeZone.toString()
10:07:24.1 (2170227)|USER_DEBUG|[2]|DEBUG|Eastern Standard Time (America/New_York)
10:07:24.1 (2216978)|CODE_UNIT_FINISHED|execute_anonymous_apex
10:07:24.1 (2925740)|EXECUTION_FINISHED

Note that I am currently in Easten Daylight Time.  SF doesn't switch the description when in DST.

I recognize that this issue is a pain.  The only foolproof way to deal with timezones is to use the ISO timezone strings like "America/New_York" but non-technos hate that.  Of course non-technos often type EST when they mean EDT and make other inconsitencies but our job it to always make it work the way they like it.