note 106070 added to intldateformatter.format

From: Date: Fri, 07 Oct 2011 11:47:54 +0000
Subject: note 106070 added to intldateformatter.format
Groups: php.notes 
Request: Send a blank email to php-notes+get-183702@lists.php.net to get a copy of this message
I hope this will save some time for others who have to struggle with different php versions on dev and prod plattform in the future: when formatting a DateTime object with a *custom pattern*, be sure to use a timestamp to pass at the IntlDateFormatter::format in order to have it working on different php versions: Example for PHP Version 5.3.5-1ubuntu7.2 (my dev machine): <?php $date = new \DateTime(); $dateFormatter = \IntlDateFormatter::create( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, \date_default_timezone_get(), \IntlDateFormatter::GREGORIAN, 'EEEE' ); var_dump($dateFormatter->format($date)); // string(6) "Monday" ?> Example for PHP Version 5.3.2-1ubuntu4.9 (the prod server): <?php // same formatting as above var_dump($dateFormatter->format($date)); // bool(false) ?> When using $dateFormatter->format($date->getTimestamp()), you'll always get the formatted and localized string instead of a false. ---- Server IP: 69.147.83.197 Probable Submitter: 91.52.141.44 ---- Manual Page -- http://www.php.net/manual/en/intldateformatter.format.php Edit -- https://master.php.net/note/edit/106070 Del: integrated -- https://master.php.net/note/delete/106070/integrated Del: useless -- https://master.php.net/note/delete/106070/useless Del: bad code -- https://master.php.net/note/delete/106070/bad+code Del: spam -- https://master.php.net/note/delete/106070/spam Del: non-english -- https://master.php.net/note/delete/106070/non-english Del: in docs -- https://master.php.net/note/delete/106070/in+docs Del: other reasons-- https://master.php.net/note/delete/106070 Reject -- https://master.php.net/note/reject/106070 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183702) next »