cordova-plugin-custom-sntp

1.0.0 • Public • Published

cordova-plugin-sntp

Simple plugin to connect into SNTP servers and get accurate time.

Usage

Initialization

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    // Set the SNTP server and timeout
    cordova.plugins.sntp.setServer("a.st1.ntp.br", 10000);
}

Get time since epoch in milliseconds:

cordova.plugins.sntp.getTime(
    function(time) {
        console.log("The actual amount of milliseconds since epoch is:", time);
    },
    function(errorMessage) {
        console.log("I haz error:", errorMessage);
    }
);

Get system clock offset:

cordova.plugins.sntp.getClockOffset(
    function(offset) {
        console.log("System clock offset is:", offset);
    },
    function(errorMessage) {
        console.log("I haz error:", errorMessage);
    }
);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i cordova-plugin-custom-sntp

      Weekly Downloads

      13

      Version

      1.0.0

      License

      MIT

      Unpacked Size

      40.5 kB

      Total Files

      14

      Last publish

      Collaborators

      • deepwad