note 124441 added to function.date-default-timezone-set
| From: | Pierre-OlivierVares@php.net | Date: | Wed, 27 Nov 2019 07:39:25 +0000 |
| Subject: | note 124441 added to function.date-default-timezone-set | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213261@lists.php.net to get a copy of this message | ||
As Christopher Kramer said 9 years ago, not setting default timezone has performance impacts on PHP
5.6, and on PHP 7.1
It hasn't on php 7.2 anymore.
As I set error_reporting to 0 in my script, it doesn't seem linked to the fact it is logging
the error.
I ran its benchmark script (modified) on Linux multiple times, alternating 'on' and
'off' setting :
<?php
error_reporting(0);
$tz = ($argc > 1 && ($argv[1] == 'on')) ? 'on': 'off';
if ($tz == 'on') date_default_timezone_set(@date_default_timezone_get());
$start=mktime(0,0,0,1,1,2005);
$end=mktime(0,0,0,1,1,2020);
$t0=microtime(true);
for ($i=0; $i<50000; $i++) date("H:i:s d.m.Y",rand($start,$end));
echo "Time ($tz): ".((microtime(true) - $t0)*100)."\n";
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.168 (proxied: 109.69.192.8)
----
Manual Page -- http://php.net/manual/en/function.date-default-timezone-set.php
Edit -- https://master.php.net/note/edit/124441
Del: integrated -- https://master.php.net/note/delete/124441/integrated
Del: useless -- https://master.php.net/note/delete/124441/useless
Del: bad code -- https://master.php.net/note/delete/124441/bad+code
Del: spam -- https://master.php.net/note/delete/124441/spam
Del: non-english -- https://master.php.net/note/delete/124441/non-english
Del: in docs -- https://master.php.net/note/delete/124441/in+docs
Del: other reasons-- https://master.php.net/note/delete/124441
Reject -- https://master.php.net/note/reject/124441
Search -- https://master.php.net/manage/user-notes.php