IntroductionThe Zend_Date component offers a detailed, but simple API for manipulating dates and times. Its methods accept a wide variety of types of information, including date parts, in numerous combinations yielding many features and possibilities above and beyond the existing PHP date related functions. For the very latest manual updates, please see » our online manual (frequently synced to Subversion). Although simplicity remains the goal, working with localized dates and times while modifying, combining, and comparing parts involves some unavoidable complexity. Dates, as well as times, are often written differently in different locales. For example, some place the month first, while other write the year first when expressing calendar dates. For more information about handling localization and normalization, please refer to Zend_Locale. Zend_Date also supports abbreviated names of months in many languages. Zend_Locale facilitates the normalization of localized month and weekday names to timestamps, which may, in turn, be shown localized to other regions. Always Set a Default TimezoneBefore 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 #1 Setting a Default Timezone
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. Why Use Zend_Date?Zend_Date offers the following features, which extend the scope of PHP date functions:
|