+ Start a Discussion
MartinKMartinK 

Formatting Date Time field for Local Time zone works in Sandbox but not Production

I am using the following method to format a DateTime field in the local time zone:

 

 

string reservation =
       string.valueof(op.Reservation_Date__c.format('EEEE, MMMM d, yyyy:  HH:mm z'));

 I refer to the field on my VF page as follows: {!reservation}

In my sandbox this displays the expected result, the date time in the local time zone (EDT). In production the time is displayed incorrectly in GMT. 
To troubleshoot this I then created a new sandbox off of the production instance ( that gave the results in GMT ) The test in the new sandbox yielded  the local timezone being displayed in EDT which is correct.
Two questions:
 1) Are these bugs (Sandbox and Production yielding different results and time formatting not working in Production?)
 2) How do I work around this?
Thank you so much for your help. 

 

Best Answer chosen by Admin (Salesforce Developers) 
MartinKMartinK

Thank you for your response, It has helped me resolve down the problem.

 

The issue was in the Salesforce Sites public access user profile settings for the time zone were set to GMT. Changing this setting resolved the problem.  

 

 

 

All Answers

TheSwamiTheSwami

OutputField will display the date according to the user's time zone.  OutputText or free tag expressions will be shown in GMT.

 

Were you using the exact same VF page?

MartinKMartinK

Thank you for your response, It has helped me resolve down the problem.

 

The issue was in the Salesforce Sites public access user profile settings for the time zone were set to GMT. Changing this setting resolved the problem.  

 

 

 

This was selected as the best answer