Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default timeZoneOffsetInMinutes value causing wrong Date in "date" mode #841

Open
quememo opened this issue Jul 11, 2024 · 1 comment
Open

Comments

@quememo
Copy link

quememo commented Jul 11, 2024

Describe the bug
When using Datepicker in mode="date", the date extracted by onConfirm is not the same as the selected with the UI.

Expected behavior
Expected: To get December 2, 1998 as date when using onConfirm:
image
I get
image

To Reproduce
Add example code that reproduces the behavior.

  <DatePicker
          modal
          mode="date"
          maximumDate={new Date()}
          minimumDate={new Date(1900, 1, 1)}
          open={open}
          onConfirm={(date) => {
            console.log('🚀 ~ onDate', date)
          }}
        />

Smartphone (please complete the following information):

  • OS: iOS
  • React Native version 0.72.10
  • react-native-date-picker version 4.4.2

Proposition
I have fixed it with timeZoneOffsetInMinutes={0}. The default behavior of this Timezone offset seems to be problematic. My use case is simply allowing the user to define their birthday. I don't care about the device's timezone for this type of interaction; however, due to the default value, it affects my result. I think it should perhaps be set to 0 for 'date' usage or its use should be reevaluated.

@ARSSHEIKH
Copy link

but this is only for ios what for android?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants