Bug #54396 [Opn->Nab]: Php appears to be one day off with Julian Day count
| From: | heiglandreas@php.net | Date: | Thu, 12 Jan 2017 19:58:43 +0000 |
| Subject: | Bug #54396 [Opn->Nab]: Php appears to be one day off with Julian Day count | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206575@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54396&edit=1
ID: 54396
Updated by: heiglandreas@php.net
Reported by: satovey at yahoo dot com
Summary: Php appears to be one day off with Julian Day count
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Win7
PHP Version: 5.3SVN-2011-03-26 (SVN)
Block user comment: N
Private report: N
New Comment:
The jdtogregorian function expects an integer as parameter. You are passing a float which is
converted to int via floor. Therefore the date is not what you expect it to be. Have a look at http://php.net/manual/en/function.jdtogregorian.php#43470
for an explanation how to get the value you expected.
Previous Comments:
------------------------------------------------------------------------
[2011-03-26 18:02:28] satovey at yahoo dot com
Description:
------------
I am using Xamp on Windows 7 x64 in case that is relevant.
The following two sites:
http://www.fourmilab.ch/documents/calendar/
http://quasar.as.utexas.edu/BillInfo/JulianDateCalc.html
are in agreement. They produce a Julian Day count of 2455646.5 for 3/26/2011.
However, PHP's jdtogregorian() functions produces the following:
2455646.5 => 3/25/2011 || 2455647.5 => 3/26/2011
Test script:
---------------
$julianDayCntI = 2455646.5;
$julianDayCntII = 2455647.5;
$gregDateI = jdtogregorian($julianDayCntI);
$gregDateII = jdtogregorian($julianDayCntII);
echo "$julianDayCntI => $gregDateI || $julianDayCntII => $gregDateII <br />";
Expected result:
----------------
I do not have the mathematical skills to fix this bug, so I will leave correcting this bug it up to
those who are more mathematically astute.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54396&edit=1