1.0.3 • Published 3 years ago

react-native-ntp-client v1.0.3

Weekly downloads
712
License
-
Repository
github
Last release
3 years ago

react-native-ntp-client Build Status

React Native compatible implementation of the NTP Client Protocol.

Getting Started

  1. Install the module with: yarn add react-native-ntp-client or npm install react-native-ntp-client.
  2. Install the native required dependency: yarn add react-native-udp or npm install react-native-udp.
  3. If you are using React Native < 0.60, link react-native-udp running react-native link react-native-udp. If you are using React Native >= 0.60 the native dependencies are auto-linked on both platforms.
  4. If you are using React Native >= 0.60, on iOS run pod install in ios directory.

Usage

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é))
});

Contributors

License

Licensed under the MIT license.