php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41386 Month order output wrong
Submitted: 2007-05-13 19:39 UTC Modified: 2007-05-13 19:58 UTC
From: andy at needcheats dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.2 OS: WinXP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andy at needcheats dot com
New email:
PHP Version: OS:

 

 [2007-05-13 19:39 UTC] andy at needcheats dot com
Description:
------------
I am getting an incorrect output of a list of months.
Starts with December instead of January!
**NOT** having same problem with Days and Years using the same loop method!

Reproduce code:
---------------
$now = date('n');
for($i = 1; $i <= 12; $i++)
{
  $month = date("F", mktime(0, 0, 0, $i, 0, 0));
  $value = date("m", mktime(0, 0, 0, $i, 0, 0));
  echo $i.'-'.$value.'-'.$month.'<br/>';
}

Expected result:
----------------
The loop should output the following:

1-01-January
2-02-February
3-03-March
4-04-April
5-05-May
6-06-June
7-07-July
8-08-August
9-09-September
10-10-October
11-11-November
12-12-December

Actual result:
--------------
Following unexpected result is produced:

1-12-December
2-01-January
3-02-February
4-03-March
5-04-April
6-05-May
7-06-June
8-07-July
9-08-August
10-09-September
11-10-October
12-11-November

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-13 19:58 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Day \"0\" is the last day of the previous month...
 [2012-06-04 10:49 UTC] kai dot business at childheart dot info
They say that this isn't a bug, but it'd be far easier to code if the months started off normally. 

I have to code January as 2 just to make it line up correctly which is nonsense.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 13:01:30 2024 UTC