The NTP reader is a class for reading data from the NTP server over the UDP / TCP port. The class allows:
- read data from the NTP server
- transfer output data to the Carbon library for processing time
The recommended way to is via Composer:
composer require filipsedivy/ntp
It requires PHP version 7.1 and supports PHP up to 7.2.
To run the tests, you must run this command via Composer
composer test
$socket = FilipSedivy\NTP\Socket::create('europe.pool.ntp.org');
$datetime = FilipSedivy\NTP\Client::getDateTime($socket);
// Carbon library
echo $datetime->toDateTimeString();
// Alternatively DateTime functions
echo $datetime->format(...);