Reputation: 183
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
.
Upvotes: 0
Views: 529
Reputation: 1155
I'm googling for you. How about checking this question and answer.
The way I see it use react-native-device-info
for getting device setting timezone
Upvotes: 1