0

I have just started using the react-day-picker library. I have the following code sandBox which is a fork of the range with 2 inputs example,

https://codesandbox.io/s/w6vnlox29l

I have it working the way I want but I want to input the dates as MM/DD/YYYY instead of the default format, YYYY-MM-DD. When I add the following attributes

<DayPickerInput
  value={from}
  format="M/D/YYYY"
  formatDate={formatDate}
  parseDate={parseDate}
  placeholder="MM/DD/YYYY"
  onDayChange={this.handleFromChange}
  dayPickerProps={{
    selectedDays: [from, { from, to }],
    modifiers,
    disabledDays: {
      after: new Date(),
    },
    numberOfMonths: 2,
    toMonth: new Date(),
  }}
/>

I can no longer correctly enter the date in the input field the date. When I remove the format, formatDate and parseDate attributes the date picker input functions the way I expected. I have read the documentation but think I may be missing something simple. How can I use the input text box and date picker with dates formatted as MM/DD/YYYY?

career2
  • 11
  • 1
  • 5
  • What do you mean by saying that you can no longer correctly enter the date? Codesandbox example page works as expected for me. – kengho Dec 07 '17 at 14:48
  • I used the Codesandbox example as a starting point then tried to modify it so I could enter dates in the MM/DD/YYYY format instead of the default format. Try the Codesandbox link I provided, and enter in a date in the input text box, the date jumps to the month but a new date or year can not be added. – career2 Dec 08 '17 at 12:25
  • There is a bug fix in the works for this issue. https://github.com/gpbl/react-day-picker/issues/584 – career2 Dec 08 '17 at 16:09

0 Answers0