Zend date

05.Jul.2010

To format Zend date by local settings of your multilingual website can be done easy if you are using following script. This script shows you a simple usage of Zend date you will be using when want to format date according to locale settings of current language on your multilingual website.

1
2
$date = new Zend_Date(strtotime(date('Y-m-d')), null, 'de_DE');
echo $date->toString(Zend_Date::WEEKDAY_SHORT . ', ' . Zend_Date::DAY . '. ' . Zend_Date::MONTH_NAME . ' ' . Zend_Date::YEAR . '.');

Explanation of Zend date:

When creating a Zend date:

$date = new Zend_Date();

you can pass locale for current language. This way, Zend will know what format to use. It will even be able to print day names in current language.

Using function:

$date->toString();

makes it easy to output date. You can send various format types, and for that purpose, you can use constants from Zend_Date.

List of all constants can be found on Zend Framework website.