You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

accutime

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accutime

A JS library that fetches time from multiple sources and returns the time.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

accutime

Accurate time for the browser.

Use me

Browser

<script src="https://cdn.jsdelivr.net/npm/accutime@latest/dist/accutime.min.js"></script>

CommonJS

npm i accutime
const accutime = require('accutime');

ESM

npm i accutime
import accutime from 'accutime';

Usage

getTime

accutime.getTime();

Get the time.

Returns:

{
    "datetime": "2024-02-01T11:33:36.841Z",
    "timezone": "Europe/London",
    "utc_offset": "+00:00",
    "unix": 1706787216841
}

ntpJS

accutime.ntpJS(timezone: string)

Parameters:

  • Timezone: (optional) A timezone. See full list here.

Get the time from https://use.ntpjs.org/v1/time.json.

Returns:

[
    {
        "now": 1706787368.862806,
        "backoff": 375,
        "__server": "lhrlhr"
    },
    62
]

The first value in the array is the response from the server.

The second value in the array is the amount of time it took to make the request.

worldTimeApi

accutime.worldTimeApi(append: string)

Parameters:

  • append: (required) A appendix to the URL https://worldtimeapi.org/api/. In practise, you can append a timezone or ip for time at your IP. See the World Time API website for details.

Todo

  • Fix requests for the server.
  • Add real NTP for server clients.

FAQs

Package last updated on 01 Feb 2024

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc