xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 725 forks source link

Picking a date earlier than 1960 results in 20XX #118

Open bufke opened 7 years ago

bufke commented 7 years ago

Tested on Android.

  1. Create a component androidMode="spinner" (It's very hard to pick older dates without the spinner)
  2. Set date format to something like "MMMM Do, YYYY"
  3. Pick the date 1965.

The date now shows as 2065 instead of 1965. The problem is purely visual however. When I inspect onDateChange I see the 1965 date selected. I am unsure if the behavior is reproducible in ios or not.

jnrepo commented 7 years ago

This is happening on iOS as well and it also happens when you set your minDate to 1920 it defaults to 2020

jnrepo commented 7 years ago

@bufke

If you haven't found a solution. I was looking through their code and found this https://github.com/xgfe/react-native-datepicker/blob/master/index.js#L152

this worked for me:

<DatePicker minDate={'1920-01-01'} maxDate={'2017-01-01'} format={'YYYY-MM-DD'} />
conor909 commented 7 years ago

@jnrepo This didn't work for me, tried setting the minDate to 1900-01-01 but it actually sets the minDate to 2000-01-01

BrendanBerkley commented 6 years ago

@jnrepo's solution seemed to work for me. There was one caveat:

For the maxDate, I was using a JS Date object and it worked fine. For minDate, I was using a text string. When I changed the date format, I had to make sure that the minDate string followed my format specification for it to work.

qamoonsite commented 6 years ago

any solution?