function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael Degn JensenMichael Degn Jensen 

Aura Component DateTime not showing correct format

Hi,

I am showing the value of a date/time field but the format is off.
This is what I would like it to show (as show on the Page Layout):
Format from Page Layout

However this is what it looks like in my component:
Format from component

My code:
<lightning:formattedDateTime value="{!task.Task_LastModifiedDate__c}" timeZone="{!$Locale.timezone}" year="numeric" month="numeric" day="numeric" hour="2-digit" minute="2-digit" hour12="false"/>
Basically I just want to show the standard date/time format.

Thanks,
Michael
Ramesh DRamesh D
@Michael,
It works based on user datetime format settings 
https://help.salesforce.com/articleView?id=000324092&type=1&mode=1 (https://help.salesforce.com/articleView?id=000324092&type=1&mode=1)
This is how it looks for me 
User-added image
<lightning:formattedDateTime value="{!v.bdate}" timeZone="{!$Locale.timezone}" year="numeric" month="numeric" 
                                 day="numeric" hour="2-digit" minute="2-digit" hour12="false"/>

Thanks
Ramesh
Michael Degn JensenMichael Degn Jensen
Hi Ramesh,
But it doesn't make sense that one field is showing format dd-mmm-yyyy and the other dd.m.yyyy?
Thanks,
Michael
Alex Bondarenko 1Alex Bondarenko 1
Hello Michael,

I think to format date as you need you should use javascript API formatDate() method  from $A.localizationService and save it to aura attribute to display

please look at this page in aura documentation https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_format_dates.htm