Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sntp

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sntp

SNTP Client

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is sntp?

The sntp npm package is a simple Network Time Protocol (NTP) client for Node.js. It allows you to synchronize your system time with NTP servers, ensuring accurate timekeeping for your applications.

What are sntp's main functionalities?

Time Synchronization

This feature allows you to request the current time from an NTP server. The code sample demonstrates how to use the sntp package to get the current time from 'pool.ntp.org' and log it to the console.

const Sntp = require('sntp');

// Request the current time from an NTP server
Sntp.time({ host: 'pool.ntp.org', port: 123 }, (err, time) => {
  if (err) {
    console.error('Failed to get time:', err);
    return;
  }
  console.log('Current time:', new Date(time.now));
});

Custom NTP Server

This feature allows you to specify a custom NTP server to synchronize time with. The code sample shows how to get the current time from 'time.google.com' and log it to the console.

const Sntp = require('sntp');

// Request the current time from a custom NTP server
Sntp.time({ host: 'time.google.com', port: 123 }, (err, time) => {
  if (err) {
    console.error('Failed to get time:', err);
    return;
  }
  console.log('Current time from custom server:', new Date(time.now));
});

Time Offset

This feature allows you to calculate the time offset between your system time and the NTP server time. The code sample demonstrates how to get the time offset from 'pool.ntp.org' and log it to the console.

const Sntp = require('sntp');

// Request the current time and calculate the offset
Sntp.time({ host: 'pool.ntp.org', port: 123 }, (err, time) => {
  if (err) {
    console.error('Failed to get time:', err);
    return;
  }
  console.log('Time offset:', time.t);
});

Other packages similar to sntp

Keywords

FAQs

Package last updated on 18 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc