I have a custom setting of List type and it has got a field of datetime. When I create record for the custom setting and provide value to it. Does salesforce store it as it is without converting it to GMT? Because I apex I am getting what I entered not the converted value in GMT. Any thoughts?
2 Answers
Salesforce always stores the date/time in GMT.
When you save the record it converts from the logged-in user's local timezone to GMT. And when you view the record it converts back from GMT to the logged-in user's local timezone.
Salesforce does indeed store your value in GMT (UTC) and then converts it back. If you want to display the date time in the logged in user's time zone on a visualforce page, you need to use <apex:outputfield>
instead of <apex:outputtext>
, that way visual force will use the locale and timezone of the user.
Outputfield (and by extend, inputfield) can only be used when bound to an sobjectfield, you can use this to render currency correctly or percentages, or any type of sobject field type.