const [startTime, setStartTime] = useState(moment(new Date()).toDate());
<DatePicker
showIcon
selected={startTime}
onChange={(date) => handleStartDateChange(date)}
dateFormat="MM-dd-yyyy"
maxDate={moment(startTime).toDate()}
placeholderText="Select a date"
className='margin-bt5'
/>
This my date picker component when i trying work on mobile responsive it's throws error invalid time value. same code i have in my desktop version it's working correctly no error were throws
You can try making:
which will return native js Date object. What matters in ur case is whether datepicker works with Date() object, Moment object or plain string, or integer timestamp. You have to clarify this. Most probably it doesnt accept ur date because:
will return Moment.js date object.