|
Hi,
maybe this is a silly question, but I encountered an obliquity with Zend_Date and its localization. When I pass a locale in the contructor of Zend_Date I tought it would be the same as when I pass it to the get method. But the enclosed code snippet resolves different date strings for en_US but equals for de_DE locale. Is there sth wrong or am I wrong? Thanks, flo <?php // Define root directory and set include paths. $rootDir = dirname(dirname(__FILE__)); define('ROOT_DIR', $rootDir); set_include_path( get_include_path() .PATH_SEPARATOR.ROOT_DIR.'/lib/' ); require_once dirname(dirname(__FILE__)).'/lib/Zend/Loader.php'; Zend_Loader::registerAutoload(); $date = '2009-03-07 23:54:28'; // de_DE $zd = new Zend_Date($date); echo $zd->get(Zend_Date::DATE_SHORT, 'de_DE')."<br />\n"; // 07.03.09 $zd = new Zend_Date($date, null, 'de_DE'); echo $zd->get(Zend_Date::DATE_SHORT)."<br />\n"; // 07.03.09 // en_US $zd = new Zend_Date($date); echo $zd->get(Zend_Date::DATE_SHORT, 'en_US')."<br />\n"; // 3/7/09 $zd = new Zend_Date($date, null, 'en_US'); echo $zd->get(Zend_Date::DATE_SHORT)."<br />\n"; // 7/3/09 ?> |
|
You are already giving an localized date within the constructor.
But you omitted the locale so the browser is used as source. Have you checked if the set date is identical after the initiation ? I assume that $date is in german format, and as your third line says it's in english format (even when it's in german format) month and day is switched. When the values are low enough (below 13) there is no way to detect an error. Example: 05-03-2009: In de_DE 05.March But in en_US 03.May Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com ----- Original Message ----- From: "fs" <[hidden email]> To: <[hidden email]> Sent: Wednesday, March 11, 2009 11:51 PM Subject: [fw-i18n] Zend_Date and L10N > > Hi, > > maybe this is a silly question, but I encountered an obliquity with > Zend_Date and its localization. > > When I pass a locale in the contructor of Zend_Date I tought it would be > the > same as when I pass it to the get method. But the enclosed code snippet > resolves different date strings for en_US but equals for de_DE locale. Is > there sth wrong or am I wrong? > > Thanks, > flo > > <?php > // Define root directory and set include paths. > $rootDir = dirname(dirname(__FILE__)); > define('ROOT_DIR', $rootDir); > set_include_path( > get_include_path() > .PATH_SEPARATOR.ROOT_DIR.'/lib/' > ); > require_once dirname(dirname(__FILE__)).'/lib/Zend/Loader.php'; > Zend_Loader::registerAutoload(); > $date = '2009-03-07 23:54:28'; > > // de_DE > $zd = new Zend_Date($date); > echo $zd->get(Zend_Date::DATE_SHORT, 'de_DE')."<br />\n"; // 07.03.09 > $zd = new Zend_Date($date, null, 'de_DE'); > echo $zd->get(Zend_Date::DATE_SHORT)."<br />\n"; // 07.03.09 > > // en_US > $zd = new Zend_Date($date); > echo $zd->get(Zend_Date::DATE_SHORT, 'en_US')."<br />\n"; // 3/7/09 > $zd = new Zend_Date($date, null, 'en_US'); > echo $zd->get(Zend_Date::DATE_SHORT)."<br />\n"; // 7/3/09 > ?> > -- > View this message in context: > http://www.nabble.com/Zend_Date-and-L10N-tp22466307p22466307.html > Sent from the Zend I18N/Locale mailing list archive at Nabble.com. |
| Powered by Nabble | Edit this page |
