react-native-date-picker icon indicating copy to clipboard operation
react-native-date-picker copied to clipboard

[ANDROID] If the minimumDate and maximumDate are set on 'date' mode, by openening the datepicker it shows the minimumDate, not the maximumDate

Open angelinaromashkoo opened this issue 11 months ago • 7 comments

If I set the minimumDate and maximumDate on Android, when I open the Datepicker, it will show me the dates starting from the minimum date (instead of showing me the maximum date like it happens on iOS). So for example, I set the minimumDate to be '1924-03-06' and the maximumDate is '2007-03-06'. When I open the datepicker on Android I see this (6st March 1924 is the minimum date, not the selected one). On IOS it works perfect ANDROID Screenshot 2024-03-06 at 17 25 25

IOS Screenshot 2024-03-06 at 17 25 56

The expected behaviour would be to see when I open the datepicker on 'date' mode the maximum date, even if the minimumDate is set

<DatePicker
        modal
        mode="date"
        locale={i18next.language}
        open={datePickerOpen}
        date={
          dateOfBirth !== ''
            ? DateTime.fromISO(dateOfBirth).setLocale(i18next.language).toJSDate()
            : DateTime.now().setZone('utc').setLocale(i18next.language).toJSDate()
        }
        onConfirm={onSelectDateOfBirth}
        onCancel={toggleDatePicker}
        maximumDate={minDate}
        minimumDate={maxDate}
      />
  • OS: Android
  • React Native version: "0.71.13"
  • react-native-date-picker version: 4.3.3

angelinaromashkoo avatar Mar 06 '24 16:03 angelinaromashkoo

Same issuse :(

linhkiubo98 avatar Mar 20 '24 07:03 linhkiubo98

Is there any workaround for this?

VaibhavValere avatar Apr 05 '24 11:04 VaibhavValere

Is there any workaround for this?

You need to adjust either the start date or the selected date to fall within the selectable range of values.

linhkiubo98 avatar Apr 06 '24 03:04 linhkiubo98

You have to set the date property value the same as the maximumDate property value

Ammarlio avatar Jun 10 '24 07:06 Ammarlio

Same issue, any update on solution, android specific issue.

Sandeep145XamRN avatar Jul 21 '24 10:07 Sandeep145XamRN

Same issue. Is there update about this?

danhidsan avatar Sep 04 '24 07:09 danhidsan

@danhidsan please refer to @Ammarlio comment. Ensure that the date prop is passed in the same format as the maximumDate prop.

Example: const [date, setDate] = useState(new Date(new Date().setFullYear(new Date().getFullYear() - 10))); const [open, setOpen] = useState(false); <DatePicker modal open={open} date={date} mode={'date'} maximumDate={new Date(new Date().setFullYear(new Date().getFullYear() - 10))} onConfirm={newDate => { setOpen(false); setDate(newDate) }} onCancel={() => { setOpen(false); }} />

Sandeep145XamRN avatar Sep 04 '24 18:09 Sandeep145XamRN