php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1896 date('t',..) function does not return 29 as last day for Feb 2000
Submitted: 1999-07-27 14:58 UTC Modified: 1999-08-04 15:07 UTC
From: atanas at intransco dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.11 OS: Linux
Private report: No CVE-ID: None
 [1999-07-27 14:58 UTC] atanas at intransco dot com
$last_day = date ('t', mktime(1,1,1,$month,1,$year));
if (($year == '2000') and ($month == '02'))
    {$last_day = 29;}

/* for building a calendar, I needed a loop from 1 to last_day_in_month
checkdate(..) returned correctly 29 for Feb 2000 as last valid day 
getting straight at the last day using date('t',...) - the script above 
returns 28 days
Of course, the "fix" is easy, but better fix the function internally:

Any year evenly divisible by 400 is a leap year!

*/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-27 15:07 UTC] rasmus at cvs dot php dot net
It certainly does on my Linux box:
eg.
 echo date ('t', mktime(1,1,1,2,29,2000));
This prints 29 for me.  It doesn't on your box?
 [1999-08-04 15:07 UTC] rasmus at cvs dot php dot net
No response from user and unable to replicate problem.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 30 23:00:01 2026 UTC