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

Using Different Time Servers

Zend_TimeSync's default behavior for requesting a time is to request it from the first given server. But sometimes it is useful to set a different time server from which to request the time. This can be done with the setServer() method. To define the used time server set the alias as a parameter within the method. To get the actual used time server call the getServer() method. It accepts an alias as a parameter which defines the time server to be returned. If no parameter is given, the current time server will be returned.

<?php
$server 
= new Zend_TimeSync(array('generic'  => 'ntp:\\0.pool.ntp.org',
                                  
'fallback' => 'ntp:\\1.pool.ntp.org'));
$server->addServer('sntp:\\internal.myserver.com''additional');

$actual $server->getServer();
$server $server->setServer('additional');

Zend Framework