Bug #16594 Updated: mktime() when passed a 0 for the day of the month to get the last day is broken
| From: | hholzgra@php.net | Date: | Sun, 14 Apr 2002 12:35:01 +0000 |
| Subject: | Bug #16594 Updated: mktime() when passed a 0 for the day of the month to get the last day is broken | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-4948@lists.php.net to get a copy of this message | ||
ID: 16594
Updated by: hholzgra@php.net
Reported By: lchang@cc.gatech.edu
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: FreeBSD 4.5
PHP Version: 4.1.2
Assigned To: hholzgra
Previous Comments:
------------------------------------------------------------------------
[2002-04-14 08:34:12] hholzgra@php.net
intended behaviour
day zero is the day before the first day of
the given month, so it is obviously the last
day of the month *before* the given one
------------------------------------------------------------------------
[2002-04-14 02:34:05] lchang@cc.gatech.edu
When you use mktime(0,0,0,<month>,<day>,<year>) and specify 0 as the
day to get the last day of the month, the last day of the month
returned is off. It seems that the months are all off by 1 after
January. So with mktime(), for February, the last day is the 31st, for
March it is the 28th, for April it is the 31st, etc. And instead
February should be the 28th, March the 31st, and April the 30th,
etc...
<?php
//Last day should be 28, but is 31
$day = getdate( mktime(0,0,0,2,0,2002) );
print 'The last day for February is: ' . $day[mday]
.'<br>';
//Last day should be 31, but is 28
$day = getdate( mktime(0,0,0,3,0,2002) );
print 'The last day for March is: ' . $day[mday];
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16594&edit=1