|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-04-14 08:34 UTC] hholzgra@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 14:00:02 2025 UTC |
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]; ?>