|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
14 + 28 = ?
Subscribe to this entry?

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

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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-29 10:50 UTC]
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: Sun Apr 14 06:01:28 2024 UTC