Req #64148 [Opn->Nab]: function strtotime seems to be inaccurate
| From: | rasmus@php.net | Date: | Tue, 05 Feb 2013 01:41:15 +0000 |
| Subject: | Req #64148 [Opn->Nab]: function strtotime seems to be inaccurate | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176442@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64148&edit=1
ID: 64148
Updated by: rasmus@php.net
Reported by: jeromystewart at gmail dot com
Summary: function strtotime seems to be inaccurate
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: WIN SERVER 2008 VIA IIS
PHP Version: 5.3.21
Block user comment: N
Private report: N
New Comment:
If you fed it UTC times, you would be right. But you didn't. strtotime() will use
the current timezone and try to create the correct Unix timestamp from that. Try
your script like this:
echo strtotime('2011-03-12 00:00:00 UTC')/(60*60*24);
Previous Comments:
------------------------------------------------------------------------
[2013-02-05 01:29:28] jeromystewart at gmail dot com
Description:
------------
My version of PHP wasn't on the list, it is actually 5.3.8 on WIN2008 (ISS)
When calculating the unix timestamp for a given day (see Test Script) I wouldn't expect there
to be a remainder at all.
The test script below demonstrates that there is a remainder ... and that remainder changes from the
13th to the 14th of March 2011.
When I ran the same script on my linux host I got the following
15045.291666667
15046.291666667
15047.291666667
15048.291666667
At least with the above, the remainder is consistent.
See below for the actual result on the windows server 2008 running IIS
Test script:
---------------
echo strtotime('2011-03-12 00:00:00')/(60*60*24);
echo '<hr>';
echo strtotime('2011-03-13 00:00:00')/(60*60*24);
echo '<hr>';
echo strtotime('2011-03-14 00:00:00')/(60*60*24);
echo '<hr>';
echo strtotime('2011-03-15 00:00:00')/(60*60*24);
echo '<hr>';
Expected result:
----------------
Expected Result:
15045.0
<hr>
15046.0
<hr>
15047.0
<hr>
15048.0
<hr>
Actual result:
--------------
Actual Result:
15045.333333333
<hr>
15046.333333333
<hr>
15047.291666667
<hr>
15048.291666667
<hr>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64148&edit=1