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

DateTime Format

I'm using a custom controller and having trouble getting the date/time field to display correctly.


<apex:outputLabel value="Class Date" for="ClassDate"/>
<apex:inputText id="ClassDate" value="{!ClassDateTime}"/>

 The field displays as 'Mon Mar 07 10:20:00 GMT 2011'


I need this to display, in the correct timezone (SCT), with a 'yyyy-MM-dd HH:mm:ss' format. 



Try changing apex:inputText to apex:inputField.


I thought an InputField would require a sObject.  Is that not the case or is there a way to use an sObject with a custom controller?


Yes, you are correct. You maybe able to use the object field as a variable instead of binding directly to a dataTime variable. This thread may also assist but I'm not sure if it works for input fields: