React Native compatible implementation of the NTP Client Protocol.
- Install the module with:
yarn add react-native-ntp-client
ornpm install react-native-ntp-client
. - Install the native required dependency:
yarn add react-native-udp
ornpm install react-native-udp
. - If you are using React Native < 0.60, link
react-native-udp
runningreact-native link react-native-udp
. If you are using React Native >= 0.60 the native dependencies are auto-linked on both platforms. - If you are using React Native >= 0.60, on iOS run
pod install
in ios directory.
import ntpClient from 'react-native-ntp-client';
ntpClient.getNetworkTime("pool.ntp.org", 123, (error, date) => {
if (error) {
console.error(error);
return;
}
console.log(date); // Mon Jul 08 2013 21:31:31 GMT+0200 (Paris, Madrid (heure d’été))
});
Licensed under the MIT license.