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
PRepakaPRepaka 

How to get the User timezone in S-Control

hi

 

 

can u please tell me how to retrieve the User timezone in s-control?

 

var user = sforce.connection.getUserInfo();
alert("your timezone is: " + user.userTimeZone);

 

if i give like that i got the time zone like this America/Chicago.

 

 

but i want the complete time zone like

 

(GMT-06:00) Central Standard Time (America/Chicago)

 

Please help me how to get this.

Best Answer chosen by Admin (Salesforce Developers) 
Karthi_VeluKarthi_Velu

var user = sforce.connection.getUserInfo();
if(user!=null)
{
UserTimeZoneName = user.userTimeZone;
}

All Answers

ArtabusArtabus

There are 2 solutions

 

First one, do a describeSObjects() for the User object and analyse the picklist values for the field TimeZoneSidKey. You will get all values allowing you to match the master and displayed value (what you were retrieving is the master value)

 

The second solution (the simplest one) is to do a simple SOQL query :

select tolabel(TimeZoneSidKey) from user where id='00520000000xxxxxxx' limit 1

 

JL

Karthi_VeluKarthi_Velu

var user = sforce.connection.getUserInfo();
if(user!=null)
{
UserTimeZoneName = user.userTimeZone;
}
This was selected as the best answer