Get the time zone with React Native

I found it is better to get the actual timezone ID (such as America/New_York) and then set your server program to work using that timezone at the beginning. To get that, use the react-native-device-info library: https://www.npmjs.com/package/react-native-device-info

import DeviceInfo from 'react-native-device-info';

console.log(DeviceInfo.getTimezone());   //   'America/New_York'

If you get an error about ‘tvOS’ during compilation, see this fix: https://github.com/rebeccahughes/react-native-device-info/issues/286

Leave a Comment