php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43444 date('F', $timestamp) returns wrong month
Submitted: 2007-11-29 10:34 UTC Modified: 2007-11-29 10:50 UTC
From: anter dot x at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: anter dot x at gmail dot com
New email:
PHP Version: OS:

 

 [2007-11-29 10:34 UTC] anter dot x at gmail dot com
Description:
------------
Function date('F', $timestamp) returns wrong month name.

NOTE:
print mktime(0, 0, 0, 2); // 1172700000
print mktime(0, 0, 0, 3); // 1175115600

Reproduce code:
---------------
print date('F', mktime(0, 0, 0, 2));
print date('F', mktime(0, 0, 0, 3));

Expected result:
----------------
February
March

Actual result:
--------------
March
March

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-29 10:50 UTC] jani@php.net
It's because mktime() defaults to the day of current date if the day parameter is omitted. From the manual page for mktime(): "Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time."

And as february this year had only 28 days and you're giving it 29, it overflows to march. No bug here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 10:01:28 2024 UTC