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

Always Set a Default Timezone

Before using any date related functions in PHP or Zend Framework, first make certain your application has a correct default timezone, by either setting the TZ environment variable, using the date.timezone php.ini setting, or using date_default_timezone_set(). In PHP, we can adjust all date and time related functions to work for a particular user by setting a default timezone according to the user's expectations. For a complete list of timezone settings, see the CLDR Timezone Identifier List.

Example 164. Setting a Default Timezone

// timezone for an American in California
// timezone for a German in Germany

When creating Zend_Date instances, their timezone will automatically become the current default timezone! Thus, the timezone setting will account for any Daylight Savings Time (DST) in effect, eliminating the need to explicitly specify DST.

Keep in mind that the timezones UTC and GMT do not include Daylight Saving Time. This means that even if you define per hand that Zend_Date should work with DST, it would automatically be switched back for the instances of Zend_Date which have been set to UTC or GMT.

Zend Framework