-
-
Notifications
You must be signed in to change notification settings - Fork 410
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
Issue with timezones on iOS #61
Comments
I have same Issue. |
my workaround: moment(date).add(date.getTimezoneOffset() * -1, 'minutes') |
It appears there's also a difference with the way the date and time is reported on android vs ios. When I console.log the value of the selected date (Mar 24 2020) here's what I get:
Note that I'm only using the date selection. Both devices are set the same timezone (GMT-05:00). |
Came looking into a similar issue. It seems the picker returns the picked date and the current time in a UTC datetime stamp. example... To get it back to local time requires the reverse. Use this function in the import * as Localization from 'expo-localization';
import { format } from 'date-fns';
import { zonedTimeToUtc } from 'date-fns-tz';
const onDatePickerChange = async (event, pickedDateString) => {
console.log(pickedDateString);
if (event.type === 'set') {
const localizedDate = zonedTimeToUtc(pickedDateString, Localization.locale);
console.log(localizedDate.toISOString());
const dateOnlyUSAFormat = format(localizedDate, 'dd-MM-y');
console.log(dateOnlyUSAFormat);
}
setIsDatePickerVisible(false);
}; It will log Hopefully that helps someone else. Took a while to figure out what was going on. 👍 |
🎉 This issue has been resolved in version 7.5.0 🎉 If this package helps you, consider sponsoring us! 🚀 |
Hi! I have the same issue, and I am using the version that supposedly comes with the solution to the problem. (v 7.5.0) |
@genomanetwork please open a new issue with a repro. |
Bug
In years between 1981-1989 _onChange method return wrong GMT and timezone offset.
The issue is here: https://github.com/react-native-community/react-native-datetimepicker/blob/master/src/datetimepicker.ios.js#L54
So let me describe issue.
When I pick 1st May 1990 I get 30 Apr and 21:00. It's ok. Because it is ISO string. In my timezone it is 1 May 00:00.
But when I change year to 1989 I get 30 Apr and 20:00.
console.log('timezoneoffset', date.getTimezoneOffset());
still returns -180 which means 3 hours difference. And in this case when I work with date in my timezone, I actually have 30 Apr 23:00. Why that? I see _onChange method handled by native module. This is the only I found.Environment info
React native info output:
Library version: 2.1.0
The text was updated successfully, but these errors were encountered: