#48187 [NEW]: DateTime::diff() corrupting microtime() result

2009-05-07 Thread wavetrex at gmail dot com
From: wavetrex at gmail dot com
Operating system: Windows 2003 Server
PHP version:  5.3.0RC2
PHP Bug Type: Date/time related
Bug description:  DateTime::diff() corrupting microtime() result

Description:

calling DateTime::diff() seems to corrupt the result returned by
microtime(), so it returns the wrong time after this function has been
called

Reproduce code:
---
";
var_dump(microtime());
var_dump(time());
var_dump(date(DATE_ATOM));

var_dump($date1->diff($date2));

var_dump(microtime());
var_dump(time());
var_dump(date(DATE_ATOM));
echo "";

?>

Expected result:

Expecting the 2nd microtime to be slightly bigger ( by a few miliseconds )
than first.

instead, it's a totally wrong 5 seconds distance (or maybe other
arbitrary value)

date() and time() seem to be unaffected


Actual result:
--
before calling diff:
string(21) "0.98425000 1241761004"

after it:
string(21) "0.25882200 1241709345"


-- 
Edit bug report at http://bugs.php.net/?id=48187&edit=1
-- 
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48187&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48187&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48187&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48187&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48187&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48187&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=48187&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=48187&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=48187&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=48187&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=48187&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=48187&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=48187&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48187&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=48187&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=48187&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=48187&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=48187&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=48187&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=48187&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=48187&r=mysqlcfg



#48187 [Fbk->Opn]: DateTime::diff() corrupting microtime() result

2009-05-08 Thread wavetrex at gmail dot com
 ID:   48187
 User updated by:  wavetrex at gmail dot com
 Reported By:  wavetrex at gmail dot com
-Status:   Feedback
+Status:   Open
 Bug Type: Date/time related
 Operating System: Windows 2003 Server
 PHP Version:  5.3.0RC2
 New Comment:

@jani:

I'm using microtime() multiple times to determine how long some 
complex parts of the script take to execute, when I noticed weird 
differences.

Also, while the second microtime() call after diff() is wrong, the 
third seems to be ok, just like calling the function resets some 
internal variable that was broken during execution of diff()

I prepared a script on my server:
http://wt.ath.cx/diff.php
The code for this script is here:
http://wt.ath.cx/diff.txt

Server configuration:
http://wt.ath.cx/phpinfo.php

Time difference between the two calls:

Expected result:
3.814697265625E-5 (a few microseconds)
Actual result:
-142455.45035195 (??)

Your script:
http://wt.ath.cx/jani.php
... also has the error.

If this probably occurs on my server, I'm thinking... it might be 
timezone related ? I'm sure yours and mine are different. (check my 
phpinfo.php to see date/time settings)

P.S.
While investigating, I noticed that in some rare cases it doesn't 
happen, and after Ctrl-R it gives the erroned value again. Try 
reloading the page a few times in case 1st time it shows the correct 
values.

I'll keep experimenting with the new 5.3.0 time functions and see if 
some other errors appear.


Previous Comments:


[2009-05-09 04:15:40] j...@php.net

Try this script instead: (I can't reproduce this..)

diff($date2));

var_dump($begin_u, microtime(true));
var_dump($begin_t, time());
var_dump($begin_a, date(DATE_ATOM));
?>


----

[2009-05-08 05:42:58] wavetrex at gmail dot com

Description:

calling DateTime::diff() seems to corrupt the result returned by
microtime(), so it returns the wrong time after this function has been
called

Reproduce code:
---
";
var_dump(microtime());
var_dump(time());
var_dump(date(DATE_ATOM));

var_dump($date1->diff($date2));

var_dump(microtime());
var_dump(time());
var_dump(date(DATE_ATOM));
echo "";

?>

Expected result:

Expecting the 2nd microtime to be slightly bigger ( by a few
miliseconds ) than first.

instead, it's a totally wrong 5 seconds distance (or maybe other
arbitrary value)

date() and time() seem to be unaffected


Actual result:
--
before calling diff:
string(21) "0.98425000 1241761004"

after it:
string(21) "0.25882200 1241709345"






-- 
Edit this bug report at http://bugs.php.net/?id=48187&edit=1



#48187 [Fbk->Opn]: DateTime::diff() corrupting microtime() result

2009-05-09 Thread wavetrex at gmail dot com
 ID:   48187
 User updated by:  wavetrex at gmail dot com
 Reported By:  wavetrex at gmail dot com
-Status:   Feedback
+Status:   Open
 Bug Type: Date/time related
 Operating System: Windows 2003 Server
 PHP Version:  5.3.0RC2
 New Comment:

float(1241919300.3593)
float(1241709350.3736)
int(1241919300)
int(1241919300)
string(25) "2009-05-10T04:35:00+03:00"
string(25) "2009-05-10T04:35:00+03:00"

( http://wt.ath.cx/jani.php )

Note: 1241709350 -> this value seems to stay almost unchanged over time

(look at my first submission: string(21) "0.25882200 1241709345" )

When I reported the difference was ~5 seconds, now it's over
200.000


Previous Comments:


[2009-05-09 20:59:00] j...@php.net

What is the output of the script I provided?

--------

[2009-05-09 06:58:21] wavetrex at gmail dot com

@jani:

I'm using microtime() multiple times to determine how long some 
complex parts of the script take to execute, when I noticed weird 
differences.

Also, while the second microtime() call after diff() is wrong, the 
third seems to be ok, just like calling the function resets some 
internal variable that was broken during execution of diff()

I prepared a script on my server:
http://wt.ath.cx/diff.php
The code for this script is here:
http://wt.ath.cx/diff.txt

Server configuration:
http://wt.ath.cx/phpinfo.php

Time difference between the two calls:

Expected result:
3.814697265625E-5 (a few microseconds)
Actual result:
-142455.45035195 (??)

Your script:
http://wt.ath.cx/jani.php
... also has the error.

If this probably occurs on my server, I'm thinking... it might be 
timezone related ? I'm sure yours and mine are different. (check my 
phpinfo.php to see date/time settings)

P.S.
While investigating, I noticed that in some rare cases it doesn't 
happen, and after Ctrl-R it gives the erroned value again. Try 
reloading the page a few times in case 1st time it shows the correct 
values.

I'll keep experimenting with the new 5.3.0 time functions and see if 
some other errors appear.



[2009-05-09 04:15:40] j...@php.net

Try this script instead: (I can't reproduce this..)

diff($date2));

var_dump($begin_u, microtime(true));
var_dump($begin_t, time());
var_dump($begin_a, date(DATE_ATOM));
?>


----------------

[2009-05-08 05:42:58] wavetrex at gmail dot com

Description:

calling DateTime::diff() seems to corrupt the result returned by
microtime(), so it returns the wrong time after this function has been
called

Reproduce code:
---
";
var_dump(microtime());
var_dump(time());
var_dump(date(DATE_ATOM));

var_dump($date1->diff($date2));

var_dump(microtime());
var_dump(time());
var_dump(date(DATE_ATOM));
echo "";

?>

Expected result:

Expecting the 2nd microtime to be slightly bigger ( by a few
miliseconds ) than first.

instead, it's a totally wrong 5 seconds distance (or maybe other
arbitrary value)

date() and time() seem to be unaffected


Actual result:
--
before calling diff:
string(21) "0.98425000 1241761004"

after it:
string(21) "0.25882200 1241709345"






-- 
Edit this bug report at http://bugs.php.net/?id=48187&edit=1



Bug #48187 [NoF->Csd]: DateTime::diff() corrupting microtime() result

2013-02-17 Thread wavetrex at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=48187&edit=1

 ID: 48187
 User updated by:wavetrex at gmail dot com
 Reported by:wavetrex at gmail dot com
 Summary:DateTime::diff() corrupting microtime() result
-Status: No Feedback
+Status: Closed
 Type:   Bug
 Package:Date/time related
 Operating System:   Windows 2003 Server
 PHP Version:5.3.0RC2
 Block user comment: N
 Private report: N

 New Comment:

This is a very old bug ;)
It appears that in my current version on the same server 5.3.20, it's not 
occurring anymore.

Using PHP VC9 compiled executable now on Apache VC9 running as a module.

Who knows what strange overflow caused it back then. There have been many 
versions since and it appears that it has been solved with one of them.


Previous Comments:

[2013-02-18 00:33:57] php-bugs at lists dot php dot net

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


[2011-01-30 11:26:12] s...@php.net

Is it VC6-based build? If yes, could you try a VC9-based build instead?


[2010-08-13 20:59:29] alpha_centurion at hotmail dot com

Reproduced on Win32 XP SP3 with Apache 2.2.15 and php 5.3.2-Win32-VC6-x86

Only seems to impact web requests as same script (by jani) does not evidence 
the same error when run on the command line.


[2010-08-10 07:01:03] jasonjoo dot god at gmail dot com

my test script below:
diff(new DateTime());
echo microtime(true);
?>
and my os is win32/xp
I found this isue can be reproduced under apache in handler mode, but it is no 
isue in command line mode(eg. php test.php).

for example, I got its output like this:
1281415176.9756
1281402595.446
and the wrong one only change the part following dot

my php version is 5.3.3


[2010-07-18 00:47:15] k.schroe...@php.net

Automatic comment from SVN on behalf of k.schroeder
Revision: http://svn.php.net/viewvc/?view=revision&revision=301359
Log: Test for #48187




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

https://bugs.php.net/bug.php?id=48187


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=48187&edit=1