0

I have the same problem asked about here, where the date displayed by the lightning:formattedDateTime component does not match the date field that's its value.

I attempted the answer chosen in the original post, which is to add timeZone="{!$Locale.timezone}", like so:

<lightning:formattedDateTime value="{!v.application.Seat_Deposit_Due_Date__c}" year="numeric" month="short" day="2-digit" weekday="long" timeZone="{!$Locale.timezone}"/>

But the date is still incorrect; one day less than the field's date.

I also tried the poster's set of attributes and values like below, but the date remained off.

<lightning:formattedDateTime value="{!v.application.Seat_Deposit_Due_Date__c}" year="numeric" month="numeric" day="numeric" timeZone="{!$Locale.timezone}"/>

Am I missing something to make the original answer work in my case? Or is there a new solution?

  • 1
    what the org's timezone and whats the running user's timezone? – Pranay Jaiswal Jan 23 at 15:38
  • The same: (GMT-05:00) Eastern Standard Time (America/New_York) – Gabriel Rivera Jan 23 at 15:44
  • if you just print {!v.application.Seat_Deposit_Due_Date__c} what value do you get? – Pranay Jaiswal Jan 23 at 15:45
  • {!v.application.Seat_Deposit_Due_Date__c}: 2020-01-24. Through lightning:formattedDateTime: Thursday, Jan 23, 2020 – Gabriel Rivera Jan 23 at 15:50
  • I tried <lightning:formattedDateTime value="2020-01-24" year="numeric" month="short" day="2-digit" weekday="long" /> by changing my user and org timezone to (GMT-05:00) Eastern Standard Time (America/New_York) and properly print Friday, 24 Jan 2020 – Pranay Jaiswal Jan 23 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.