You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a maximumDate is provided, but a minimumDate is not, the Android date picker does not allow the user to go earlier than the Unix epoch (1970-01-01 00:00).
The workaround I found was to manually set an unrealistic minimumDate. You can also remove the maximum date, but in our case that is not an option.
Reproducible sample code
import{useState}from"react";import{SafeAreaProvider,SafeAreaView}from"react-native-safe-area-context";importDateTimePickerfrom"@react-native-community/datetimepicker";import{View,Button,Text}from"react-native";exportdefaultfunctionBugReport(){const[show,setShow]=useState(false);const[withMaxDate,setWithMaxDate]=useState(true);const[withMinDate,setWithMinDate]=useState(false);return(<SafeAreaProvider><SafeAreaView><Viewstyle={{gap: 5}}><View><Text>
Max date: {withMaxDate ? "on" : "off"}; Min date:{" "}{withMinDate ? "on" : "off"}</Text></View><ButtononPress={()=>setShow(true)}title="Select a date"/><ButtononPress={()=>setWithMaxDate((c)=>!c)}title="Toggle max date"/><ButtononPress={()=>setWithMinDate((c)=>!c)}title="Toggle min date"/>{show&&(<DateTimePickermaximumDate={withMaxDate ? newDate(2006,0,1) : undefined}minimumDate={withMinDate ? newDate(1900,0,1) : undefined}value={newDate(1970,0,2)}mode={"date"}onChange={()=>setShow(false)}/>)}</View></SafeAreaView></SafeAreaProvider>);}
Facing the same issue. We have our maximum date set to three years from the current date and no minimum date. However what @czycha suggested does work and is a temporary workaround for thus
FiratDede
added a commit
to FiratDede/datetimepicker
that referenced
this issue
Nov 5, 2024
Bug report
Summary
If a
maximumDate
is provided, but aminimumDate
is not, the Android date picker does not allow the user to go earlier than the Unix epoch (1970-01-01 00:00).The workaround I found was to manually set an unrealistic
minimumDate
. You can also remove the maximum date, but in our case that is not an option.Reproducible sample code
https://github.com/czycha/rn-datepicker-min-date-bug has this code here
Steps to reproduce
Describe what you expected to happen:
Environment info
npx react-native info
output:datetimepicker version: 8.2.1
Android version: 15
Expo: 51.0.36
The text was updated successfully, but these errors were encountered: