|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35658 date function slower than in 5.0.5
Submitted: 2005-12-13 12:57 UTC Modified: 2005-12-13 13:44 UTC
From: renffeh at yahoo dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: 5.1.1 OS: Windows XP
Private report: No CVE-ID: None
 [2005-12-13 12:57 UTC] renffeh at yahoo dot com
Has the date function slowed from PHP 5.0.5 to PHP 5.1.1?

When testing with the code below, my output is:
PHP 5.0.5: 0.044
PHP 5.1.1: 0.938

If I comment out the $d = ... line, my output is:
PHP 5.0.5: 0.003
PHP 5.1.1: 0.001 I know it's the date function that is responsible for the slower time.

Has anyone else seen evidence of this?

(I'm using Windows XP SP2 with the PHP Zip packages)

Mike Heffner

Reproduce code:
function get_microtime() {
	list($usec,$sec) = explode(" ",microtime());
	return((float)$sec + (float)$usec);
$t1 = get_microtime();
for ($x=0; $x<10000; $x++) {
	$d = date("Y-m-d H:i:s");
$t2 = get_microtime();


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-13 13:00 UTC]
Do you have error reporting set to E_ALL | E_STRICT?
 [2005-12-13 13:11 UTC] renffeh at yahoo dot com
I just checked this on PHP 4.4.1 and the execution time was similar to that of 5.0.5

 [2005-12-13 13:15 UTC]
Please answer to Derick.
 [2005-12-13 13:27 UTC] renffeh at yahoo dot com
I added E_STRICT to the error reporting and saw the messages about the time zone, so I added "date.timezone = US/Eastern" to my PHP.ini and now my execution time is 0.125. Adding 'date_default_timezone_set("US/Eastern");' to my script brings it down to 0.095. Still slower, but much better.
 [2005-12-13 13:38 UTC]
Okay, then all is fine - it's expected to be a bit slower. But please, do not use a setting like US/Eastern, use America/New_York or similar.
 [2005-12-13 13:44 UTC] renffeh at yahoo dot com
Will do... thanks for your help!
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 12:03:37 2021 UTC