krzysztofmazur / ntp-client
NTP client
Installs: 2 460
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: ^7.0|^7.1
This package is not auto-updated.
Last update: 2025-03-24 17:37:43 UTC
README
Ntp-client is a PHP library to getting time from NTP server. It supports UPD and TCP protocol.
Installation
Run composer command
composer require krzysztofmazur/ntp-client
Usage
<?php
use KrzysztofMazur\NTPClient\Impl\UdpNtpClient;
$client = new UdpNtpClient('pool.ntp.org', 123);
var_dump($client->getUnixTime());
or
<?php
use KrzysztofMazur\NTPClient\Impl\UdpNtpClient;
use KrzysztofMazur\NTPClient\Impl\CompositeNtpClient;
$clients = [
new UdpNtpClient('pool.ntp.org', 123),
new UdpNtpClient('ntp.pads.ufrj.br', 123)
];
$client = new CompositeNtpClient($clients);
var_dump($client->getTime(new DateTimeZone('Europe/Warsaw')));
License
MIT