ID: 25288 Updated by: [EMAIL PROTECTED] Reported By: josep dot gorro at trendcomms dot es -Status: Open +Status: Bogus Bug Type: Calendar related Operating System: WinNT PHP Version: 4.3.1 New Comment:
The fault here lies with Excel. Julian Day Counts start at noon, rather than midnight. Combine this with the timezone of your computer and you likely have your first day of error. Excel also believes that February 29, 1900 is a valid day. This accounts for day two of your error. Previous Comments: ------------------------------------------------------------------------ [2003-08-28 06:25:20] josep dot gorro at trendcomms dot es Description: ------------ I'm generating a function to calculate a date in Julian day count to be used in excel spreadsheet. Always I obtain a 2 days difference. Is this a bug? Reproduce code: --------------- <?php // This is the date that I would to convert $jd1 = GregorianToJD (8,28,2003); print "$jd1\n"; $gregorian1 = JDToGregorian ($jd1); print "$gregorian1\n"; // This is the initial excel's date counter $jd2 = GregorianToJD (1,1,1900); print "$jd2\n"; $gregorian2 = JDToGregorian ($jd2); print "$gregorian2\n"; // This is the REAL (not bogus) day counter $total=$jd1 - $jd2 + 2; print "Excel value: ".$total; ?> Expected result: ---------------- Without the correction ($total=$jd1 - $jd2;) the result is: 2452880 8/28/2003 2415021 1/1/1900 Real counter: 37859 Whit the correction ($total=$jd1 - $jd2 + 2;) the result is: 2452880 8/28/2003 2415021 1/1/1900 Real counter: 37861 First one isn't correct, second one is fine. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25288&edit=1