|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-12-14 03:27 UTC] john at designingforbusiness dot com
Description:
------------
While using date("d", mktime(0,0,0,11+1,0,2008); to retrieve the number of days in November I continually have 29 returned. While December and other months are correct.
Reproduce code:
---------------
foreach($this->vacationDays as $entry) {
$nowdate = split("/", $entry[1]);
$ourDate = mktime(0,0,0,(int)$nowdate[0],(int)$nowdate[1],(int)$nowdate[2]);
$ourMonth = date("M", $ourDate);
$ourDay = date("D", $ourDate);
$ourYear = date("o", $ourDate);
$firstDayOfMonth = mktime(0,0,0, $nowdate[0], 1 , $nowdate[2]);
$firstDayInMonth = date("D", $firstDayOfMonth);
$daysInMonth = date("d", mktime(0,0,0,(int)($nowdate[0]+1), 0, (int)$nowdate[2]));
$day_of_week = $firstDayInMonth;
switch($day_of_week) {
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
if(isset($currentMonth) && $ourMonth != $currentMonth) {
$currentMonth = $ourMonth;
$this->startCalendarMonth($ourMonth, $ourYear);
$day_count = $this->shootBlanks($blank);
for($day_num = 1; $day_num <= $daysInMonth; $day_num++)
{
echo "<td>$day_num</td>";
$day_count++;
if($day_count > 7) {
echo "</tr>\n <tr>";
$day_count = 1;
}
}
$this->endCalendar();
}
Expected result:
----------------
The expected result is that November 2008 would return 30 days and December 2008 return 31 days.
Actual result:
--------------
The current result is Nov 2008 returns 29 days and December 2008 returns 31. Clearly the problem is with November.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 08:00:02 2025 UTC |
Ever heard of date("t") ?