-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
DatePickerAndroid choose wrong default date #21906
Comments
Which Android API level is this on? I've run into a similar bug in production a few months ago, and I had a hard time working out what was going on because it was so unexpected. Before you read any further, I upgraded JavaScriptCore and my problems went away. What happened was: const momentDate = moment();
const date = momentDate.toDate();
console.log(date); // Fri Oct 26 2018 21:58:01 GMT+0000 (AUS Eastern Summer Time)
console.log(date); // Fri Oct 27 2018 08:58:01 GMT+1100 (AUS Eastern Summer Time) First access:
Any subsequent access:
The workaround I found that reliably worked at the time, which I still cannot wrap my head around because it's ridiculous: const momentDate = moment();
const date = momentDate.toDate();
// Get the string representation, and assign it to a constant or variable.
// If the value of toString() is NOT assigned to something, it will continue to be unreliable,
// though I'm pretty sure any optimising compiler would immediately eliminate this as "dead code",
// as we're not even going to use corruptDateString.
const corruptDateString = date.toString();
// Happy days. Correct date, time and offset.
console.log(date); // Fri Oct 26 2018 21:58:01 GMT+1100 (AUS Eastern Summer Time) |
@wbercx ,I'm doing at API 24 Android 7.0 I had tried your method and it failed. Below is failed sample.
the output is
And the calendar selection still wrong. seems the calendar is using UTC time . Does this mean I need to remove GMT offset +0800 every time when select the date? |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
i've upgrade to 0.59 and above and seems it fixed the bug. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
I use moment code as below. As I am in Malaysia, so the timezone is +8
As I set code as below
The default select date had become yesterday. (The round select is yesterday which is wrong. But the today date word is highlighted which is correct.)
Then when I tried change the hour to 8. the default select date become today.
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
Memory: 216.81 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.11.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 19.1.0, 20.0.0, 23.0.1, 23.0.3, 24.0.3, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3
API Levels: 16, 17, 18, 19, 21, 23, 24, 25, 26, 27
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: ^16.5.2 => 16.5.2
react-native: ^0.57.2 => 0.57.2
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-check-box: 2.0.2
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
react-native-tab-view: 0.0.69
The text was updated successfully, but these errors were encountered: