`format` vs static `formatObject`
The `formatObject` is slower! `format` is more then 10-13 times faster! (on PHP 5.5) Use the `format` method instead of the static `formatObject`.
php -v
PHP 5.5.26-1+deb.sury.org~precise+1 (cli) (built: Jun 15 2015 10:04:01)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
<?php
$n = 3000;
$dt = new \DateTime('2015-01-03 12:32:44');
$df = new IntlDateFormatter('hu_HU', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
$df->setPattern('MMMM dd');
$time[] = microtime(true);
for($i=0;$i<$n;$i++) {
$a = IntlDateFormatter::formatObject($dt, 'MMMM dd', 'hu_HU');
}
echo "$a\n";
$time[] = microtime(true);
for($i=0;$i<$n;$i++) {
$a = $df->format($dt);
}
echo "$a\n";
$time[] = microtime(true);
for($j=1;$j<count($time);$j++) {
printf("%fs\n", $time[$j]-$time[$j-1]);
}
?>
`formatObject` : 0.458248 s
`format` : 0.033759 s