Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81154 views
1
var Sntp = require('../lib');
2
3
// All options are optional
4
5
var options = {
6
host: 'nist1-sj.ustiming.org', // Defaults to pool.ntp.org
7
port: 123, // Defaults to 123 (NTP)
8
resolveReference: true, // Default to false (not resolving)
9
timeout: 1000 // Defaults to zero (no timeout)
10
};
11
12
// Request server time
13
14
Sntp.time(options, function (err, time) {
15
16
if (err) {
17
console.log('Failed: ' + err.message);
18
process.exit(1);
19
}
20
21
console.log(time);
22
console.log('Local clock is off by: ' + time.t + ' milliseconds');
23
process.exit(0);
24
});
25
26
27