ntpclient
v1.6.2
Published
A TypeScript implementation of the NTP Client Protocol
Downloads
1,224
Readme
NTPClient
TypeScript implementation of the NTP Client Protocol. Based on node-ntp-client.
Prerequisites
Installation
ℹ️ This is a hybrid CommonJS / ESM module.
Run yarn add ntpclient
or npm i ntpclient
.
import {NTPClient} from 'ntpclient';
new NTPClient()
.getNetworkTime()
.then(date => console.log(date)) // 2017-09-20T15:29:09.443Z
.catch(err => console.error(err));
// or
new NTPClient({
server: 'de.pool.ntp.org',
port: 123,
replyTimeout: 40 * 1000, // 40 seconds
})
.getNetworkTime()
.then(date => console.log(date)) // 2017-09-20T15:29:09.443Z
.catch(err => console.error(err));
// or
new NTPClient('de.pool.ntp.org', 123, 40 * 1000)
.getNetworkTime()
.then(date => console.log(date)) // 2017-09-20T15:29:09.443Z
.catch(err => console.error(err));