question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timezone conversion is not working properly on iOS 14

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

Hello Guys, I’ve noticed and I been receiving users feedbacks that all dates and other functions related to dates (like local push notifications, reminders, and others) are wrong on the latest iOS 14 on my app.

Basically, the app/system is not being able to convert the timestamp that we get from our back-end (it’s on UTC0) to the user timezone. So, for example, I’m on UTC -3 and all timestamps on the app are being presented to me 3 hours later.

The odd thing about this is that is only happening with iOS 14 users. I use the same codebase and test it out on iOS 14 devices, <= iOS 13 devices, Android Devices with different android versions, and the only one that presents the issue was the devices with the newer iOS 14.

I’ve been searching for answers or fixes related to that for the past couple of weeks and so far I wasn’t able to fix that, so at least I wanted to know if this is a React Native issue or an Apple issue or maybe both? This app is live for quite some time now and this logic as well, I really didn’t want to refactor the whole timezone logic. (and even don’t know if I can afford the time spent).

Any help would be awesome!

React Native version:

System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
    Memory: 22.51 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.4
    Yarn: 1.22.5
    npm: 6.14.6 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.1, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2
      System Images: android-23 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 
    Xcode: 12.1- /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_265 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.0 => 0.63.0 
    react-native-macos: Not Found

Steps To Reproduce

It’s pretty much explained in the description, I don’t believe that is a code issue, at least for now.

Expected Results

Users should be able to get the correct timestamp on their apps on the iOS14.

Snack, code example, screenshot, or link to a repository:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
enrickdlcommented, Oct 28, 2020

@ravirajn22 Thank you so much for your help. I didn’t know about that situation with date strings and the StackOverflow link help me out to find a solution! Basically, I’m checking the date sting and adding the “Z” to the end. Now, iOS 14 is able to show and understand the right date on my app. cheers 👍

1reaction
ravirajn22commented, Oct 27, 2020

https://stackoverflow.com/a/13363791/1250311

Also read this Date.parse which it uses, https://tc39.es/ecma262/#sec-date.parse

The above links pretty clearly solves your problem and tells why iOS 14 way of handling date-time string without timezone is correct according to new es5 javascript spec matching ISO 8601.

Post here if you have any doubts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If you can't change the time or time zone on your Apple device
On your iPhone or iPad · Go to Settings > General > Date & Time. · Turn off Set Automatically. Is this setting...
Read more >
iOS Date timezone conversion not working - Stack Overflow
UTC: formatter.timeZone = TimeZone(abbreviation: NSTimeZone.default.abbreviation()!) To display local datetime, i use the GMTTimeZone.
Read more >
Convert Dates & Times to Different Time Zones on iOS Without ...
When you're finished, tap on "Done." A list of eight different popular time zones with the city name and country will appear for...
Read more >
Time Zone Converter – Time Difference Calculator
Find the exact time difference with the Time Zone Converter – Time Difference Calculator which converts the time difference between places and time...
Read more >
Best Time Zone Converter Apps for iPhone and iPad in 2022
But our fascination is not just about the looks. The app has some great features as well, from geo-based location support to calendar ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found