5

How can I display today's date in format like Monday December, 29th 2014 modifying this

<apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!today()}" /> </apex:outputText>

this will display like 29/12/2014

Thank you

3
  • Means you have to display date like in this format 29/12/2014 ? Dec 29 '14 at 10:07
  • My code didnt show up, I edit it. No, but this one Monday December, 29th 2014
    – LoveLace
    Dec 29 '14 at 10:12
  • Date formatting is always a bit tough in Visualforce - a gentle reminder from the platform that the output is supposed to be an artefact of the running user's locale and language. I might have burned my fingers a few times! :-) Dec 29 '14 at 18:56
6

You can use this:

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

That will display something like: Monday December, 29 2014

The date formatting is based on simple date format. Note that to add "st","th","nd","rd" to the days additional coding is required, you may need an apex solution.

4

Try this

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

It produces the following when I test in my dev org

enter image description here

Take a look at Java Simple Date Format for additional details and other possibilities

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

4
  • Why it shows 2015???
    – LoveLace
    Dec 29 '14 at 11:20
  • Great point. Didn't notice. Just updated. Changed the year from YYYY to yyyy. Now showing 2014 as it should. Dec 29 '14 at 11:24
  • what is the difference with my answer? an image that displayed the wrong date at first? Dec 29 '14 at 13:10
  • 1
    The answers are no different. You must have answered while I was still typing my answer. Dec 29 '14 at 13:34

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.