Not all time servers are always available to return their time. Servers may be unavailable during maintenance, for example. When the time cannot be requested from the time server, you will get an exception.
Zend_TimeSync is a simple solution that can handle multiple time
servers and supports an automatic fallback mechanism. There are two supported ways; you
can either specify an array of time servers when creating the instance, or you can add
additional time servers to the instance using the
$server = new Zend_TimeSync(array('0.pool.ntp.org',
There is no limit to the number of time servers you can add. When a time server can not
Zend_TimeSync will fallback and try to connect to the
next time server.
When you supply more than one time server- which is considered a best practice for
Zend_TimeSync- you should name each server. You can name your
servers with array keys, with the second parameter at instantiation, or with the second
parameter when adding another time server.
$server = new Zend_TimeSync(array('generic' => '0.pool.ntp.org',
'fallback' => '1.pool.ntp.org',
'reserve' => '2.pool.ntp.org'));
Naming the time servers allows you to request a specific time server as we will see later in this chapter.