41

I need this date format in a visualforce page: "December 14, 2013". I can't seem to find the format options for visualforce. I read that it's the same as the java messageformat class options, but I cannot find a list for that either.

A little help would be much appreciated

2

3 Answers 3

58

This will print the date out in the format December 14, 2013. The documentation can be found here

<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 
</apex:outputText>

or if all you need is the current date printed out in that format then you can use this:

<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!NOW()}" />
</apex:outputText>

Have a look at the JavaDocs for SimpleDateFormat for the various date formats. (Thanks to @PeterKnolle for the correct link)

2
  • 1
    Perfect, thank you
    – fourq
    Dec 14, 2013 at 18:50
  • When a date is being passed to the param, how is that transformed? The docs for apex:param say only strings, numbers, and booleans can be used. How is the date transformed into one of those values? I'm assuming it's miliseconds since Jan 1, 1970 Jan 6, 2021 at 23:31
11
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 
</apex:outputText>

link to full doc: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm

2
  • 1
    Yeah I had this link, but it doesn't show all the options and the link to the java docs is broken. Thank you though!
    – fourq
    Dec 14, 2013 at 18:44
  • Is it possible to add the 'th' or 'st' after the date day numeral?
    – Robs
    Sep 20, 2020 at 23:02
-2
<apex:outputText value=" {0,date,EEE MMM d, yyyy}">
    <apex:param value="{!a.CreatedDate}"/>
</apex:outputText>

Output : Fri July 22, 2016

This will eliminate the time from date field

1
  • 3
    this was not the format the OP asked for help with
    – cropredy
    Jul 27, 2015 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.