Apparently if I want to format a date to my own format ie. 1 June 2016 10:44 am I can only do this with outputText but output text does not respect the users time zone so everything is GMT. If I use outputField it automatically converts it to the users time zone but I have no control over the format it displays it in. Does someone know how to get my custom format to display in the users time zone? I don't care which I use I just want to show it my way in the proper time zone
This respects users time zone but I cannot control formatting
<apex:outputField value="{!c.CreatedDate}"/>
or This does not respect users time zone but I can control formatting
<apex:outputText value="{0,date,dd MMM YYYY h:mm a}">
<apex:param value="{c.CreatedDate}"/>
</apex:outputText>
This method is called from the controller when page is called and populates the variable csComments with records
public void ShowComments() {
disp = true;
RetrieveAcctInfo();
caseNo = System.currentPagereference().getParameters().get('cn');
System.debug('Case No: ' + caseNo);
cd = [select id, AccountId, Priority from Case where CaseNumber=:caseNo];
if (acctid != cd.AccountId) { disp = false; errMsg = 'Access Restricted'; }
else {
csComments = [select Comment__c, CreatedDate from CSPComments__c where CaseCom__c=:cd.id ORDER BY CreatedDate DESC];
ccCount = csComments.size();
}
initpri = new List<SelectOption>();
initpri.add(new SelectOption('None',' -- Select Priority --', true));
initpri.add(new SelectOption('Level 1','1 - System Down'));
initpri.add(new SelectOption('Level 2','2 - Funtioning with Errors'));
initpri.add(new SelectOption('Level 3','3 - System Issue'));
initpri.add(new SelectOption('Level 4','4 - Non Critical Issue'));
inpri = cd.Priority;
curpri = inpri;
}
This is the part of the page that is showing the results. The manager wants my date to be in the approved style of 1 June 2016 11:26 am
<apex:pageBlock id="cl" rendered="{!disp}">
<!-- Retrieved {!ccCount} comments<br /> -->
<table><tr><th>Date/Time</th><th>Comment</th></tr>
<apex:repeat value="{!csComments}" var="c">
<tr style="padding:4px 0px 4px 0px">
<td padding-right="4px">
<!-- <apex:outputText value="{0,date,d MMM YYYY h:mm a}"><apex:param value="{!c.CreatedDate}"/></apex:outputText> -->
<apex:outputField value="{!c.CreatedDate}" />
</td>
<td><textarea class="dtarea" rows="4" cols="60" disabled="true">{!c.Comment__c}</textarea></td>
</tr>
</apex:repeat>
</table>
</apex:pageBlock>
DateTime.Format(...)
and a getter such aspublic String FormattedDate { get { return SomeDateTime.Format(...); } }
.