Android minimumDate and maximumDate not working
See original GitHub issueBug
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:
- Created 4 years ago
- Reactions:14
- Comments:11 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m seeing this bug on Android when using
mode="datetime"
and settingmaximumDate={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.
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 !