datetimepicker
datetimepicker copied to clipboard
1970-01-01 is undefined
For example my initialState is 1990-01-01. If I scroll to 1970-01-01, the app crashes.
In the code below I have labeled where it crashes because it says value cannot be undefined. If I scroll past 1970 to 1963 or something, it works fine. This is a bug because I cannot have the date 1970-01-01.
Right now my workaround is if selectedDate is undefined, I set it to new Date('1970-01-01T00:00:00.000Z')
<DateTimePicker
display="spinner"
value={someDate}
maximumDate={new Date()}
onChange={(e, selectedDate) => {
console.log('date', selectedDate)
// selectedDate is undefined when I scroll datepicker to the year 1970, with date as January 1st.
const currentDate = selectedDate || someDate
setSomeDate(currentDate)
}}
textColor="#fff"
/>
datetimepicker version: 3.0.6
iOS: 14.2
This might be because of epoch time. I am not sure but check this post.