0

I'm currently working on a react native project to get the user timezone, I'm using new Date() to get the timezone because it's returning :

Wed Jul 15 2020 17:37:12 GMT+0700

so i can split the result and get the GMT+0700 only. But when i'm trying to change my phone timezone to GMT+0800 in Date & Time setting, the new Date() seems not affected and still return GMT+0700. Did anyone know where the new Date() get it's date from?

Update :
I just found out that enabling Debug Remote JS is causing this problem. So what Stark Jeon mention on answer below is correct that React Native got it's new Date() from device-info, and why it's not changing is because i'm enabling Debug Remote JS and i think the app will get the new Date() from the metro js server if you enable Debug Remote JS.

Sandy Rizky
  • 163
  • 2
  • 14
  • 1
    Did you completely terminate the app and run it from scratch when you changed your phone's timezone? Also, did that change stick? You may have your phone set to get that information from the cell signal. – T.J. Crowder Jul 15 '20 at 07:54
  • 1
    Maybe try [this](https://stackoverflow.com/questions/1091372/getting-the-clients-timezone-offset-in-javascript) then reinstall your app and restart the device. – holydragon Jul 15 '20 at 07:57
  • i already reinstall & restart my device, but still no luck. The device time is changed to GMT+0800, but the app time still not changed. – Sandy Rizky Jul 15 '20 at 08:16

1 Answers1

1

I'm googling for you. How about checking this question and answer.

Reference

The way I see it use react-native-device-info for getting device setting timezone

Stark Jeon
  • 1,107
  • 9
  • 24
  • thanks for googling for me, I already try that solution yesterday. Right now i want to know why the app time is not the same as device time, even after changing the device timezone – Sandy Rizky Jul 15 '20 at 08:19