We have built LDS forms using lightning-record-edit-form, lightning-input-field tag is used for date which displays standard locale date format as per documentation. The problem is, it is always displaying date in medium format of locale i.e. Jul 1, 2021 not in short format 06/01/2021. Any pointers to display date in mm/dd/yyyy format using lightning-input-field? Is this a salesforce limitation?

We cannot change the tag to lightning-input field and add apex since such change will defeat the purpose of using LDS and will result in revamp of all 20+ forms just for 1 date format issue.

  • I believe this is something with setting of your user. For me with CZ locale i have displayed the date as 28.2.2022, if i login as someon with EN locale i have it like 2/28/2022.
    – Damecek
    Commented Sep 3, 2021 at 7:27
  • User is using en_US locale, only in LDS form with lightning-input-field is showing date in medium format instead of short format otherwise in lightning experience it is mm/dd/yyyy Commented Sep 3, 2021 at 7:32

1 Answer 1

   console.log('handle submit');

   const fields = event.detail.fields;
   fields.Travel_Dates_Sent_to_PS__c = false;

   if (this.updatetype=="cancel"){
      let todaydate = this.formatDate();

formatDate() {
   let d = new Date();
   let month = '' + (d.getMonth() + 1);
   let day = '' + d.getDate();
   let year = d.getFullYear();
   if (month.length < 2) 
       month = '0' + month;
   if (day.length < 2) 
       day = '0' + day;
   return [day, month ,year,  ].join('/');

Please refer this link for more details

  • 1
    Links can stop working so it'd be great if you can add some of those relevant details to your answer with an edit Commented Sep 3, 2021 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .