I am trying to set a default value to the date input field in the lightning record edit form (Today + 90 days). I have done the below code but it is not recognized in MMM d, yyyy format.

var someDate = new Date(new Date().getTime()+(90*24*60*60*1000)); //added 90 days to todays date
var mon = this.getMonth(someDate.getMonth()+1);
var dat = someDate.getDate();
var yea = someDate.getFullYear();
var f= mon+' '+dat+', '+yea; //example - Oct 29,2021

enter image description here

How shall I convert this to a proper date format? this.getMonth is just translating numbers to equivalent months like 1 - Jan, 2 - Feb

UPDATE: Tried the below code as well but still the same issue.

    console.log(new Intl.DateTimeFormat('en-US', { dateStyle: 'medium'}).format(someDate));
  • 1
    The docs say to set value to an ISO 8601 string (YYYY-MM-DD), though that's for a lightning-input specifically and I assume you're using lightning-input-field which may not work the same way. Is an option here to set the default value at the field-level so that way it's consistent across your org?
    – nbrown
    Commented Oct 29, 2021 at 15:17
  • Nope, it's the standard Effective Date on Opportunities and I am not seeing any option to set the default value
    – Akash
    Commented Nov 1, 2021 at 9:42

2 Answers 2


Tried the below solution on Friday didn't seem to work. But on Monday its working suddenly. Hope this will helps others too.

var someDate = new Date(new Date().getTime()+(90*24*60*60*1000)); //added 90 days to todays date
return someDate.toISOString();

Also for reference adding a screenshot for the record edit form field

enter image description here


I may be rehashing the above but FWIW I was struggling with this "Your entry does not match the allowed format MMM d, yyyy." error as well. It was occurring every time I tried setting the date in my controller (JS) file. I tried fussing with date-format attributes (short, medium, etc) on my lightning-input control but that did not help. The below (primarily what is describe above) is how I finally got past the error:


<lightning-input type="date" name="myDate" value={myDate} label="My Date"></lightning-input>


this.myDate= new Date('7/4/2022').toISOString();

You must log in to answer this question.

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