php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61135 gregoriantojd() returns incorrect date for some dates
Submitted: 2012-02-18 17:26 UTC Modified: 2012-02-19 04:43 UTC
From: t dot m dot guymer at thomasguymer dot co dot uk Assigned:
Status: Not a bug Package: *Calendar problems
PHP Version: 5.3.10 OS: Linux
Private report: No CVE-ID: None
 [2012-02-18 17:26 UTC] t dot m dot guymer at thomasguymer dot co dot uk
Description:
------------
I am using gregoriantojd() to return the Julian date for some months in the year 2011. It gives the correct answer for 10 of the months, but August and September just get returned as "0".

Test script:
---------------
echo "The 1st of January 2011 is " . gregoriantojd(01, 01, 2011) . PHP_EOL;
echo "The 1st of February 2011 is " . gregoriantojd(02, 01, 2011) . PHP_EOL;
echo "The 1st of March 2011 is " . gregoriantojd(03, 01, 2011) . PHP_EOL;
echo "The 1st of April 2011 is " . gregoriantojd(04, 01, 2011) . PHP_EOL;
echo "The 1st of May 2011 is " . gregoriantojd(05, 01, 2011) . PHP_EOL;
echo "The 1st of June 2011 is " . gregoriantojd(06, 01, 2011) . PHP_EOL;
echo "The 1st of July 2011 is " . gregoriantojd(07, 01, 2011) . PHP_EOL;
echo "The 1st of August 2011 is " . gregoriantojd(08, 01, 2011) . PHP_EOL;
echo "The 1st of September 2011 is " . gregoriantojd(09, 01, 2011) . PHP_EOL;
echo "The 1st of October 2011 is " . gregoriantojd(10, 01, 2011) . PHP_EOL;
echo "The 1st of November 2011 is " . gregoriantojd(11, 01, 2011) . PHP_EOL;
echo "The 1st of December 2011 is " . gregoriantojd(12, 01, 2011) . PHP_EOL;

Expected result:
----------------
The 1st of January 2011 is 2455563
The 1st of February 2011 is 2455594
The 1st of March 2011 is 2455622
The 1st of April 2011 is 2455653
The 1st of May 2011 is 2455683
The 1st of June 2011 is 2455714
The 1st of July 2011 is 2455744
The 1st of August 2011 is 2455775
The 1st of September 2011 is 2455805
The 1st of October 2011 is 2455836
The 1st of November 2011 is 2455867
The 1st of December 2011 is 2455897

Actual result:
--------------
The 1st of January 2011 is 2455563
The 1st of February 2011 is 2455594
The 1st of March 2011 is 2455622
The 1st of April 2011 is 2455653
The 1st of May 2011 is 2455683
The 1st of June 2011 is 2455714
The 1st of July 2011 is 2455744
The 1st of August 2011 is 0
The 1st of September 2011 is 0
The 1st of October 2011 is 2455836
The 1st of November 2011 is 2455867
The 1st of December 2011 is 2455897

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-19 04:40 UTC] carloschilazo at gmail dot com
Confirmed, working on a fix right now, will upload it shortly
 [2012-02-19 04:43 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2012-02-19 04:43 UTC] rasmus@php.net
There is no bug here. A leading zero denotes an octal value. 08 and 09 are not 
valid octals.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 21:05:45 2022 UTC