Formatting DATES inside VisualForce - El Toro - Find articles about Visualforce, Apex, and Salesforce in general

Print Preview

Formatting DATES inside VisualForce

This displays a field of type date or Datetime using the format MM-dd-yyy

<apex:outputText value="{0, date, MM-dd-yyyy}">
	<apex:Param value="{!Objectname.FieldNameOfTypeDate }" />

You may also use something like this

<apex:outputText value="{0, date, {!DateFormat}}">
	<apex:Param value={!Objectname.FieldNameOfTypeDate } />

Where you provide teh format in Apex, this is useful if different users view the date/times in different formats.

public String getDateFormat() {
    return 'MMMM dd yyyy';

The full reference as to what can be used on the third parameter can be found here:

comments powered by Disqus

© El Toro . IT @ 2013
Andrés Pérez