question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android minimumDate and maximumDate not working

See original GitHub issue

Bug

DateTimePicker ignores minimumDate and maximumDate properties. On IOS it works fine. As a workaround any logic can be done inside onChange

Environment info

React native info output:

 System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Memory: 1.12 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.3 - /usr/local/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.5 => 0.60.5

Library version: 2.1.0

Reproducible sample code

if (Platform.OS === 'android') {
    return (
      <DateTimePicker
        value={dateValue}
        mode={mode}
        minimumDate={minimumDate}
        maximumDate={maximumDate}
        display="spinner"
        onChange={(e, date) => {
          if (date === undefined) {
            onDismiss();
          } else {
            if (minimumDate && date < minimumDate) {
              console.log('LOWER THAT MINIMUM DATE');
            } else if (maximumDate && date > maximumDate) {
              console.log('BIGGER THAN MAXIMUM DATE');
            } else {
              onChange(date);
            }
          }
        }}
      />
    );
  }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
albullingtoncommented, Mar 9, 2020

I’m seeing this bug on Android when using mode="datetime" and setting maximumDate={new Date()}.

The date part of maximumDate works fine, but the time part allows a user to input a time hours in the future.

On iOS, everything works as expected.

3reactions
Bran72commented, Jan 24, 2020

Hey, I think this bug also is on iOS. I confirm what @mjschutz said, if minimumDate & maximumDate has same value, minimumDate is ignored. BUT in fact, if maximumDate props is passed without a well value, minimumDate doesn’t work.

I’ve ‘patched’ this by setting a condition in the RNDateTimePicker component’ props: <DatePicker value={this.state.selectedDate} minimumDate={ minDate || null } maximumDate={ maxDate || null } onChange={(e, date) => this.setState({selectedDate: date}) } />

Hope this will help !

Read more comments on GitHub >

github_iconTop Results From Across the Web

MinimumDate and MaximumDate attributes of the date picker ...
MinimumDate and MaximumDate attributes of the date picker are not working in the Android 10 version real device. same attributes are working in ......
Read more >
react-native-modal-datetime-picker - npm
A react-native datetime-picker for Android and iOS. Latest version: 14.0.1, ... The component is not working as expected, what should I do?
Read more >
DatePicker - .NET MAUI - Microsoft Learn
The DatePicker ensures that Date is between MinimumDate and MaximumDate , inclusive. If MinimumDate or MaximumDate is set so that Date is not ......
Read more >
Set MIN and MAX Selectable Dates in DatePicker Dialog in ...
However, not all the dates show availability for the slot. Knowingly, a past date is ... Step 2: Working with the activity_main.xml file....
Read more >
react-native-modal-datetime-picker/README.md - UNPKG
Supports Android and iOS](https://img.shields.io/badge/platforms-android%20|%20ios-lightgrey.svg) ... 104, ### The component is not working as expected.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found