Show date/datetime in the format you need in visualforce page

As we know generally the date/datetime format in your visualforce page will be shown based on the logged in user locale. So if you want to generalize the date format to be shown in the page



Date:

<apex:outputText value="{0,date,dd'/'MM'/'yyyy}">
    <apex:param value="{!opp.Chase_Date__c}" /> 
</apex:outputText>

This will show the date in the following format 17/02/2018

Datetime:

<apex:outputText value="{0,date,dd'/'MM'/'yyyy hh':'mm':'ss a}">
    <apex:param value="{!opp.LastModifiedDate}" />
</apex:outputText>

This will show the datetime in the following format 17/02/2018 09:30:02 am


Comments

Popular Posts