bt51 / ntp
PHP library for interacting with ntp servers
Installs: 48 152
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: >=5.3.3
Requires (Dev)
- phpspec/phpspec: 2.0.*@dev
This package is not auto-updated.
Last update: 2024-11-09 16:53:14 UTC
README
Package ntp is a simple NTP client. It supports NTP version 4 and SNTP. Note that this client currently does not take network delay into account. This means the time that is received will not be accurate to the nanosecond.
Installation
Create a composer.json in your project
{
"require": {
"bt51/ntp": "dev-master"
}
}
Read more on composer here: http://getcomposer.org
Usage
Getting the current time from an ntp server is simple.
<?php use Bt51\NTP\Socket; use Bt51\NTP\Client; $socket = new Socket('0.pool.ntp.org', 123); $ntp = new Client($socket); $time = $ntp->getTime(); var_dump($time);
The current time returned from the ntp server will be converted to a DateTime object. The timezone will always be UTC.
License
MIT