Ask a Question related to PHP Bugs, Design and Development.
-
tony2001@php.net #1
#38154 [Opn->Fbk]: PHP CLI filemtime() is wrong
ID: 38154
Updated by: [email]tony2001@php.net[/email]
Reported By: dave at smartboy dot com
-Status: Open
+Status: Feedback
Bug Type: Date/time related
Operating System: Windows XP
PHP Version: 5.1.4
New Comment:
Please try using this CVS snapshot:
[url]http://snaps.php.net/php5.2-latest.tar.gz[/url]
For Windows:
[url]http://snaps.php.net/win32/php5.2-win32-latest.zip[/url]
Not reproducible.
Previous Comments:
------------------------------------------------------------------------
[2006-09-18 06:48:33] [email]derick@php.net[/email]
Unassigning as this has nothing to do with the date code.
------------------------------------------------------------------------
[2006-07-23 04:07:27] dave at smartboy dot com
Changed test_filemtime.php to:
<?php
echo filemtime($_SERVER["SCRIPT_FILENAME"]) . "\n";
date_default_timezone_set("UTC");
echo filemtime($_SERVER["SCRIPT_FILENAME"]) . "\n";
Output is:
$ php test_filemtime.php
1153659348
1153659348
So, the return from filemtime() is not affected by the date.timezone
setting. However the value is out by 9 hours. This is the expected
return value:
$ stat -c%Z test_filemtime.php
1153626948
(this matches very closely the output of date +%s, as I had just saved
the file when running the above command)
And the difference is 9 hours
$ echo $((1153659348-1153626948))
32400
$ echo $((9*3600))
32400
------------------------------------------------------------------------
[2006-07-22 08:33:08] [email]derick@php.net[/email]
Can you get rid of the date() calls so that we can rule out that that
is the problem and not filemtime?
------------------------------------------------------------------------
[2006-07-22 01:41:08] dave at smartboy dot com
Setting date.timezone does not change the behaviour. Changing the
sample script to:
<?php
echo "default timezone: " . date_default_timezone_get() . "\n";
date_default_timezone_set("Australia/Brisbane");
echo "default timezone: " . date_default_timezone_get() . "\n";
echo date('Y-m-d H:i:s', filemtime($_SERVER["SCRIPT_FILENAME"])) .
"\n";
produces this output:
$ php test_filemtime.php
default timezone: Australia/Melbourne
default timezone: Australia/Brisbane
2006-07-22 20:35:22
Which is still 9 hours greater than it should be.
When using Apache2 SAPI, the following (correct) output is generated:
default timezone: Australia/Melbourne
default timezone: Australia/Brisbane
2006-07-22 11:35:22
Changing "Australia/Brisbane" to "UTC" changes the time that is
printed, however there is still a 9 hour difference between the value
printed by CLI (2006-07-22 10:39:47) and the value printed by Apache2
SAPI (2006-07-22 01:39:47)
------------------------------------------------------------------------
[2006-07-20 15:20:07] [email]mike@php.net[/email]
Set date.timezone to your timezone.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/38154[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=38154&edit=1[/url]
tony2001@php.net Guest
-
#40568 [NEW]: filemtime shifted by one hour on win32
From: JPlissonneauDuquene at bellhelicopter dot textron dot com Operating system: Windows XP PHP version: 5.2.1 PHP Bug Type: ... -
#38154 [Asn->Opn]: PHP CLI filemtime() is wrong
ID: 38154 Updated by: derick@php.net Reported By: dave at smartboy dot com -Status: Assigned +Status: ... -
What am I doing wrong
I am trying to fade in an image over time, however the image keeps blinking, it fades in all the time. Below is my script. on exitFrame me go to... -
#26011 [Opn->Bgs]: filemtime-problem
ID: 26011 Updated by: iliaa@php.net Reported By: final at solnet dot ch -Status: Open +Status: Bogus... -
filemtime() on Windows
I am trying to get the last modified time of an HTML file on my windows machine. The file is in a sub dir of my script dir and I can use the same...



Reply With Quote

