PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Generic Time Server Request

Requesting the time from a time server is simple. First, you provide the time server from which you want to request the time.

<?php
$server 
= new Zend_TimeSync('0.pool.ntp.org');

print 
$server->getDate()->getIso();

So what is happening in the background of Zend_TimeSync? First the syntax of the time server is checked. In our example, '0.pool.ntp.org' is checked and recognised as a possible address for a time server. Then when calling getDate() the actual set time server is requested and it will return its own time. Zend_TimeSync then calculates the difference to the actual time of the server running the script and returns a Zend_Date object with the correct time.

For details about Zend_Date and its methods see the Zend_Date documentation.

Zend Framework