This is the query I'm making:

 public List<event> evtList{get;set;}

  evtList = [select Id, subject, Who.Name, Location, StartDateTime, EndDateTime from Event where ActivityDate = TODAY and OwnerId =: UserInfo.getUserId() order by StartDateTime];

However when I call {!evt.StartDateTime} in the VF page the time is always in GMT for all of the events. Can I convert this to the local timezone?

  • What is your Organisation time zone?
    – highfive
    May 15, 2014 at 6:41

3 Answers 3


If you just want to display in the current user's time zone, just use inputfield or outputfield for the DateTime fields. These tags should display the local time zone equivalent of the raw GMT Datetime.

If you need to be able to choose which Time Zone to display in rather than just using the current user's, you can use the Apex TimeZone Class to determine the time zone offset for a particular time zone. This becomes a little complicated, but I could add some detail here if that sounds useful.


there is format function which will convert datetime from GMT to current logged in user's time zone. here is the code. date_time.format(); //return the full date/time in user's locale and time zone u can also use the following to get datetime in any timezone..

   public DateTime date_time { get; set; } // var to hold datetime
   public String defined_format { get; set;}  // define if u want in any 
  //specific format

    Public String getFormattedDatetime()
   if (date_time == null) 
      return ''; 
    else { 

        if (defined_format == null) {
           return date_time.format(); //return the full date/time in user's locale and time zone
         return date_time.format(defined_format,'IST');  //Specify Time zone like IST,CST


You can replace date_time variable with stardatetime and enddatetime.

I hope it will be helpfull to you.


SOQL queries in a client application return dateTime field values as Coordinated Universal Time (UTC) values. You can use convertTimezone() in a date function to convert dateTime fields to the user's time zone.

SELECT HOUR_IN_DAY(convertTimezone(CreatedDate)), SUM(Amount) FROM Opportunity GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))

  • Also, outputField translates automatically, and you can use the DateTime class methods to format as various time zones.
    – sfdcfox
    Oct 15, 2014 at 0:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .