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
 [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-2023 The PHP Group
All rights reserved.
Last updated: Fri Jan 27 11:05:52 2023 UTC