You need to sign in to do that
Don't have an account?

Display Time in local time on visualforce page
I know that this is a question thats gone around a lot but I still dont have a good solution to the problem
I understand that date times are stores in the salesforce database as UTC, but on standard oppertunity pages the time will correctly display as the local time, but when i display the time on the visual force page it jsut shows as UTC again!!!
I know about the apex .format() as a way to pass the visual force page a locally formatted time, but my question is this. If i am doing a query in my controller and returning that query back to the visual force page to be displayed into a grid, how do i get it as local time?
here is my code, i simplified it here...
public PageReference query() {
qryString = 'SELECT Id, account.name,stageName,truck__c,pickupDateTime__c,'+ ' items_to_donate__c, drop_off_location__c,truck_size__c,neighborhood__c FROM Opportunity '+ 'WHERE CloseDate = ' + dateStr1 + ' and '+stageQuery+' ORDER BY truck__c, pickupDateTime__c ASC' ;}}
queryResult = Database.query(qryString) ;
then on the front end i have
<apex:pageBlockTable value="{!queryResult}" var="a" id="rows" width="50%">
<apex:column ><apex:facet name="header" ><b>Pickup Time</b></apex:facet>
{!a.PickupDateTime__c} </apex:column></apex:pageBlockTable>
any help you guys can offer would be amazing!!
Try using an outputField component rather than rendering the field contents directly.
E.g.
<apex:column > <apex:facet name="header" ><b>Pickup Time</b></apex:facet> <apex:outputField value="{!a.PickupDateTime__c}" /> </apex:column>
All Answers
Try using an outputField component rather than rendering the field contents directly.
E.g.
<apex:column > <apex:facet name="header" ><b>Pickup Time</b></apex:facet> <apex:outputField value="{!a.PickupDateTime__c}" /> </apex:column>
This worked for me and keeps it simple.
Thanks
Thanks for the post,
That took care of it.