+ Start a Discussion
deepakpdeepakp 

Displaying Date in mm/dd/yyyy format in VF page

Hi All,

 

 

When I use following code I see date in  "Wed Feb 11 00:00:00 GMT 2009" format

 

 

<apex:column width="10%"> <apex:facet name="header"> <apex:commandLink action="{!search}" value="Close Date" id="cmdSort2"> <apex:param value="o.CloseDate" name="column" assignTo="{!sortExpression}" ></apex:param> </apex:commandLink> </apex:facet> <apex:outputLabel value="{!opp.CloseDate}" /> </apex:column>

 

 

When I use 

<apex:column value="{!opp.CloseDate}" width="10%"/>

 

, it displays date in "mm/dd/yyyy" .

 

What I need to do to display date in "mm/dd/yyyy" format using outputLabel?

 

Are there any functions in Visualforce expression to support this..

 

 

 

Thanks,

Deepak

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SteveAnderson41SteveAnderson41

Can you use apex:outputText instead?

 

 

<apex:page standardController="Opportunity"> <apex:outputText value="{0,date,MM/dd/yy}"> <apex:param value="{!opportunity.CloseDate}" /> </apex:outputText> </apex:page>

 

That should give you the results you want.

 

 

All Answers

SteveAnderson41SteveAnderson41

Can you use apex:outputText instead?

 

 

<apex:page standardController="Opportunity"> <apex:outputText value="{0,date,MM/dd/yy}"> <apex:param value="{!opportunity.CloseDate}" /> </apex:outputText> </apex:page>

 

That should give you the results you want.

 

 

This was selected as the best answer
deepakpdeepakp
Thanks a lot Steve. It worked.
David Roberts 4David Roberts 4
Thanks, Steve.
Still helping ten years on!
manoj nagireddy 3manoj nagireddy 3
Hi,
Deepakp

<apex:page standardController="Opportunity"> 
    <apex:form>
        <apex:pageBlock>
   <apex:pageBlockSection>
    <apex:inputField value="{!opportunity.CloseDate}" />
   </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:form>
</apex:page>

Thanks,
Manoj
Manish Pal 17Manish Pal 17
Thanks @SteveAnderson41, This Helps a lot.