In short, I have built a very simple case builder in Apex/Visualforce where you select a case starting date (DateTime) and then it sets this value as the Estimated Start Date of the case (also DateTime field).

I live in Australia GMT 10+, and have applied this value to my variable so that when I begin the case builder the default start date value is set correctly by System.NOW().

The problem is that when I make the Estimated Start Date (field) = Start Date (apex variable) I lose the timezone, as you can see via the screenshot attached.

DateTime losing time zone screenshot

The first highlighted date time is the start date, which onchange refreshes the below section, applying the start date to the estimated start date of the case itself. As you can see it is losing the GMT10+ timezone and rolling back 10 hours.

I have read several posts with no clear solution to this issue (some really messy jquery hacks that I'd like to avoid if possible). Does anyone have a way of setting this value? (My orgs company profile is set to GMT10+, and business hours is used to calculated the SLAs which is also set to GMT10+ in case you were wondering).As far as code snippet goes there is a lot of stuff that has no relevance here. I have narrowed it down to the following scenario through testing

DateTime startdate = system.Now();

startdate.format('h:mm a', 'GMT+10:00')

case.Estimate_start_date__c = startdate

  • 1
    Can you please post a snippet of your code for your input/output fields? Jul 22, 2015 at 6:53
  • Please post your code. This issue could be caused by how you are handling the DateTimes in your code. There are some DateTime methods that ignore the users timezone which could be the case
    – BarCotter
    Jul 22, 2015 at 7:12
  • Added code snippet in original post Jul 22, 2015 at 7:14

2 Answers 2


Use Apex to get User's TimeZone and offset time. e.g.

<apex:page controller="TimeZoneController">
    <apex:outputText value="{0,date,dd/MM/yyyy HH:mm:ss}">
        <apex:param value="{!NOW()+offset}"/>

public class TimeZoneController{
    public Double offset{get{
        TimeZone tz = UserInfo.getTimeZone();
        //Milliseconds to Day
        return tz.getOffset(DateTime.now()) / (1000 * 3600 * 24.0);
    public TimeZoneController(){

[Reference] https://www.xgeek.net/salesforce/display-datetime-with-timezone-in-visualforce-page/


Found the issue - in the Visualforce I was outputting to a formatted string, which was not holding the Timezone attributes. Instead I should have been using the outputField tag and not outputText wrapped in param tags.

This could not have been identified as I did not post my Visualforce code. I did not even consider this to be an issue but right enough this is where the problem lay.

You must log in to answer this question.

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