|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-02-05 01:29 UTC] 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>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 20:00:01 2025 UTC |
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);