react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

the picked date is not showing in the field when using react-datepicker with redux-form!

Open mohamed-aljane opened this issue 6 years ago • 2 comments

i am creating a form containing 2 (a start and end ) datepickers and everything is working fine i can pick the date and then use the value in the state (its functional). But my issue is when picking a date it doesn't show correctly inside the field . -its expected to look like this : December 6, 2019 4:00 PM -or in reality it looks like this : Dec you can only see the first 3 characters. how can i fix this i tried getting the value from field props and inserting it in the selected property but its not working its always the first 3 characters

render() {
   const placeholder = this.props.name === "start" ? "From" : "To";
   const { showTime, value } = this.props
   console.log(moment(value).format('LLL'))
   return (
     <div className="date-picker">
       <DatePicker
         timeFormat="HH:mm"
         selected={value ? new Date(moment(value).format('LLL')) : this.state.startDate}
         onChange={this.handleChange}
         showTimeSelect={showTime}
         dateFormat="LLL"
         dropDownMode="select"
         placeholderText={placeholder}
       />
     </div>
   );
 }
}

this is the code i actually have right now

mohamed-aljane avatar Dec 30 '19 14:12 mohamed-aljane

https://date-fns.org/v2.8.1/docs/format LLL stands for Month format in date-fns (Dec, Jan...), it's not the same as in Moment. You're passing "LLL" as dateFormat prop to DatePicker, which uses date-fns for formatting.

ao-alexi avatar Jan 07 '20 14:01 ao-alexi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 05 '20 15:07 stale[bot]