用于在未正确显示的表中显示当前月份天数的PHP脚本(事件日历)
我认为问题在于我需要编写一个switch语句,用sunmon获取tr,然后在tr中显示当月的第一天。为了让tr的日历中的日期显示在正确的星期几下,需要在此处执行这些操作吗?有没有更合乎逻辑的方法 这是我的密码:用于在未正确显示的表中显示当前月份天数的PHP脚本(事件日历),php,calendar,Php,Calendar,我认为问题在于我需要编写一个switch语句,用sunmon获取tr,然后在tr中显示当月的第一天。为了让tr的日历中的日期显示在正确的星期几下,需要在此处执行这些操作吗?有没有更合乎逻辑的方法 这是我的密码: //calendar variable $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("
//calendar variable
$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
// get the today date and store them in day month year variables
$day = date('j');
$month = date('n');
$year = date('Y');
?>
<table>
<tr>
<td>asdf</td>
<td id ="monthandyear" colspan="5"><?php echo $monthName." ".$year; ?></td>
<td>asdf</td>
</tr>
<tr>
<td class="days1">Sun</td>
<td class="days2">Mon</td>
<td class="days3">Tue</td>
<td class="days4">Wed</td>
<td class="days5">Thu</td>
<td class="days6">Fri</td>
<td class="days7">Sat</td>
</tr>
<?php
echo "<tr>";
for ($i = 1; $i < $numDays + 1; $i++){
$timeStamp = strtotime($year-$month-$i);
if ($i == 1){
$firstDay = date("w", $timeStamp);
for($j = 1; $j < $firstDay + 1; $j++){
echo "<td> </td>";
}
}
if ($i % 7 == 0) {
echo "<tr></tr>";
}
echo "<td align='center'>".$i."</td>";
}
echo "</tr>";
//日历变量
$currentTimeStamp=strotTime($year-$month-$day);
$monthName=日期(“F”,$currentTimeStamp);
$numDays=日期(“t”,$currentTimeStamp);
$counter=0;
//获取今日日期并将其存储在日-月-年变量中
$day=日期('j');
$month=日期('n');
$year=日期('Y');
?>
asdf
asdf
太阳
周一
星期二
结婚
清华大学
星期五
坐
您需要偏移第一个日期,使其位于正确的日期之下,然后表的其余部分应该从那里正确填充。这样做的最佳方式是什么?