You need to sign in to do that
Don't have an account?
Timezone problem between OutputText and OutputField
I am having a problem in a VF page that I can't seem to resolve.
The following code works fine and formats the output as a simple date. The problem is that the date displayed is the date in GMT and not the local date.
<apex:Outputtext style=" color:black; font-size: 16pt" value="{0,date,MM/dd/yyyy a}">
<apex:param value="{!recordCase.CreatedDate}" />
</apex:outputtext>
The following code displays the date in the local time but this also shows the time of the datestamp and VF errors if I try to apply formatting as above.
<apex:outputField value="{!recordCase.CreatedDate}" />
As near as I can tell, I need one of two solutions:
1) The ability to convert the field to local time in OutputText
2) The ability to format OutputField to only display date info
I've searched the discussion boards but haven't found anything that solves this.
Thanks
For those of you keeping track, this is the workaround I found:
In the class that created the RecordCase object, I used the following:
CreatedDate = formatDateTime(recordCase.CreatedDate);
Thus I was able to use the following in the VisualForce Page.
<Apex:OutputText value="{!CreatedDate}"/>
That gives me the local date without the time portion.
All Answers
Not sure about the formatting, but to display only the date, you may use Date function.
<apexutputField value="{!Date(recordCase.CreatedDate)}" />
Thanks but that doesn't seem to work, I get an error "Syntax error Missing )" for some reason but thanks. If there is a typecast function that works, that would be helpful.
For those of you keeping track, this is the workaround I found:
In the class that created the RecordCase object, I used the following:
CreatedDate = formatDateTime(recordCase.CreatedDate);
Thus I was able to use the following in the VisualForce Page.
<Apex:OutputText value="{!CreatedDate}"/>
That gives me the local date without the time portion.