1

My salesforce environment is on right Local setting all data on Salesforce Org is display as 'dd/mm/yyyy'.

Recently I build a Lightning page which display some dates.but they display as 'yyyy-mm-dd' How can I change it to 'dd/mm/yyyy' this is how it display in Salesforce. my lightnening component - there are two date fields as Start_date__c and Training_outcome_date__c.

<aura:handler name="init" action="{!c.doInit}" value="{!this}" />
<aura:attribute name="agreementRows" type="Training_Agreement__c[]"/> 

<ltng:require styles="/resource/SLDS102/assets/styles/salesforce-lightning-design-system-ltng.css" 
scripts="/resource/Jquery" /> 

<div class="slds">
<p>
    <b>   Completed Trainees  </b>
</p>
<br>
</br>
<table class="slds-table slds-table--bordered slds-max-medium-table--stacked" >
    <thead>
        <tr class ="slds-text-heading--label"> 
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Traineee Name</td>
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Workplace</td>
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Qualification</td>   
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Start Date</td>  
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Completed Date</td>
        </tr>
    </thead>
    <tbody>
        <aura:iteration var="cell" items="{!v.agreementRows}">
            <tr>
                <td data-label="Trainee Name"> {!cell.Trainee_Name__c} </td>
                <td data-label="Workplace"> {!cell.Company__c} </td>
                <td data-label="Qualification"> {!cell.Qualification_Name__c} </td>
                <td data-label="Start Date"> {!cell.Start_Date__c} </td>
                <td data-label="Completed Date"> {!cell.Training_Outcome_Date__c} </td>
            </tr>
        </aura:iteration>
    </tbody>
</table>

4

The easiest way i can think of is using outputDate. For ex:

<aura:handler name="init" action="{!c.doInit}" value="{!this}" />
<aura:attribute name="agreementRows" type="Training_Agreement__c[]"/> 

<ltng:require styles="/resource/SLDS102/assets/styles/salesforce-lightning-design-system-ltng.css" 
scripts="/resource/Jquery" /> 

<div class="slds">
<p>
    <b>   Completed Trainees  </b>
</p>
<br>
</br>
<table class="slds-table slds-table--bordered slds-max-medium-table--stacked" >
    <thead>
        <tr class ="slds-text-heading--label"> 
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Traineee Name</td>
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Workplace</td>
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Qualification</td>   
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Start Date</td>  
            <td class = "boldHeader slds-cell-wrap slds-size--1-of-7">Completed Date</td>
        </tr>
    </thead>
    <tbody>
        <aura:iteration var="cell" items="{!v.agreementRows}">
            <tr>
                <td data-label="Trainee Name"> {!cell.Trainee_Name__c} </td>
                <td data-label="Workplace"> {!cell.Company__c} </td>
                <td data-label="Qualification"> {!cell.Qualification_Name__c} </td>
                <td data-label="Start Date"> 
                <ui:outputDate value="{!cell.Start_Date__c}"/>
                </td>
                <td data-label="Completed Date"> 
                    <ui:outputDate value="{!cell.Training_Outcome_Date__c}"/>
                </td>
            </tr>
        </aura:iteration>
    </tbody>
</table>

For more info: refer https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_ui_outputDate.htm?search_text=ui:outputDate

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.