ntp-client-promise
v1.1.0
Published
Query time from NTP servers with promises
Downloads
10
Readme
Net Time Protocol Client
Query time from NTP servers
Import
- CommonJS
const { getTime } = require("ntp-client-promise")
- TypeScript
import { getTime } from "ntp-client-promise"
- ES Modules
import ntp from "ntp-client-promise" const getTime = ntp.getTime;
Usage
const date = await getTime()
date // => 2022-09-02T19:21:33.186Z
const russianTime = await getTime({
// Everything is optional
server: "ntp5.stratum2.ru",
port: 123, // 123 is default NTP port
timeout: 1000, // timeout in MS
socketType: "udp6", // udp4 or udp6 - which IP type to use
utc: false // sync with UTC time (default) or local
})