function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
zen_njzen_nj 

Any way to have DateTime field in dataTable column be displayed in local time zone instead of GMT

I have a visualforce page where I am displaying selected fields from the Case objects in a table (for list of cases).

So essentially the table would have following columns:

 

Case Number  Owner   Status  DateOpened  DateClosed

 

But what's happening is the DateOpened and DateClosed field would contain something like:

 

Tue May 29 20:19:21 GMT 2007   instead of say what's display in normal case page screen:

5/29/2007 4:19 PM

 

Is there some kind of conversion function I can use in apex code or visualforce to get the display on visualforce not to display the result in GMT format?

 

My code in apexpage to display the Open Date column is something like this:

     <apex:column >    
    <apex:facet name="header"><b>Date Opened</b></apex:facet>      {!case.createdDate}   
    </apex:column>    

 

Is there some way I can manipulate/convert this code so that it either displays the Date field with the full date and time value but in our local time zone (instead of GMT), or just to display it strictly as a Date field (no time)??

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd

This should do it:

 

 

<apex:outputField value="{!case.createdDate}"/>

 

 

 

All Answers

TehNrdTehNrd

This should do it:

 

 

<apex:outputField value="{!case.createdDate}"/>

 

 

 

This was selected as the best answer
zen_njzen_nj

Thx.

 

Once I substituted:

 

       <apex:column >    
       <apex:facet name="header"><b>Date Opened</b></apex:facet>  {!case.createdDate}
    </apex:column>   

 

with

 

       <apex:column >    
       <apex:facet name="header"><b>Date Opened</b></apex:facet>    
       <apex:outputField value="{!case.createdDate}"/>
    </apex:column>    

 

It works great!