Accurate time for the browser.
<script src="https://cdn.jsdelivr.net/npm/accutime@latest/dist/accutime.min.js"></script>
npm i accutime
const accutime = require('accutime');
npm i accutime
import accutime from 'accutime';
accutime.getTime();
Get the time.
Returns a promise that resolves to:
{
"datetime": "2024-02-01T11:33:36.841Z",
"timezone": "Europe/London",
"utc_offset": "+00:00",
"unix": 1706787216841
}
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 a promise that resolves to:
[
{
"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.
accutime.worldTimeApi(append: string)
Parameters:
- append: (required) A appendix to the URL
https://worldtimeapi.org/api/
. In practise, you can append a timezone orip
for time at your IP. See the World Time API website for details.
- Fix requests for the server.
- Add real NTP for server clients.