AP
Size: a a a
AP
AP
ИЛ
ИЛ
AP
C
ИЛ
AP
C
use Drupal\Component\Utility\Timer;
Timer::start('1');
date('Y');
debug(Timer::read('1') . ' ms');
Timer::start('2');
$timestamp = \Drupal::time()->getRequestTime();
\Drupal::service('date.formatter')->format($timestamp, 'custom', 'Y');
debug(Timer::read('2') . ' ms');
C
AP
C
AP
C
C
AP
use Drupal\Component\Utility\Timer;
Timer::start('1');
date('Y');
debug(Timer::read('1') . ' ms');
Timer::start('2');
$timestamp = \Drupal::time()->getRequestTime();
\Drupal::service('date.formatter')->format($timestamp, 'custom', 'Y');
debug(Timer::read('2') . ' ms');
AP
C
use Drupal\Component\Utility\Timer;
Timer::start('1');
for ($i = 0; $i < 1000; $i++) {
date('Y');
}
echo Timer::read('1') . ' ms';
Timer::start('2');
$timestamp = \Drupal::time()->getRequestTime();
$date_formatter = \Drupal::service('date.formatter');
for ($i = 0; $i < 1000; $i++) {
$date_formatter->format($timestamp, 'custom', 'Y');
}
echo Timer::read('2') . ' ms';
C
AP