php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54396 Php appears to be one day off with Julian Day count
Submitted: 2011-03-26 18:02 UTC Modified: 2017-01-12 19:58 UTC
From: satovey at yahoo dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3SVN-2011-03-26 (SVN) OS: Win7
Private report: No CVE-ID: None
 [2011-03-26 18:02 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-12 19:58 UTC] heiglandreas@php.net
-Status: Open +Status: Not a bug
 [2017-01-12 19:58 UTC] heiglandreas@php.net
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.
 [2017-01-12 20:35 UTC] satovey at yahoo dot com
Thanks for pointing that out.
That makes a date and time accuracy unlikely.
=-)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 07:01:31 2025 UTC