我怎样才能将星期的第一列中的第一天更改为星期日。
这是我从网站获得的代码,我一直在尝试更改日期的位置,但仍将一周的第一天显示为星期一。我怎么能把它改成星期天,提前谢谢:)
<?php
$dDaysOnPage = 37;
$dDay = 1;
if (isset($_REQUEST['year']))
{
if ($_REQUEST['year'] <> "")
{
$dYear = $_REQUEST['year'];
}
else
{
$dYear = date("Y");
}
}
else
{
$_REQUEST['year'] = date("Y");
$dYear = $_REQUEST['year'];
}
?>
<table style="margin-left:-80px;" class="table table-bordered">
<tr class="blue">
<td><?php echo $dYear; ?></td>
<th>Mo</th> <!--i change this to Sunday-->
<th>Tu</th>
<th>We</th>
<th>Th</th>
<th>Fr</th>
<th>Sa</th>
<th>Su</th>
<th>Mo</th>
<th>Tu</th>
<th>We</th>
<th>Th</th>
<th>Fr</th>
<th>Sa</th>
<th>Su</th>
<th>Mo</th>
<th>Tu</th>
<th>We</th>
<th>Th</th>
<th>Fr</th>
<th>Sa</th>
<th>Su</th>
<th>Mo</th>
<th>Tu</th>
<th>We</th>
<th>Th</th>
<th>Fr</th>
<th>Sa</th>
<th>Su</th>
<th>Mo</th>
<th>Tu</th>
<th>We</th>
<th>Th</th>
<th>Fr</th>
<th>Sa</th>
<th>Su</th>
<th>Mo</th>
<th>Tu</th>
</tr>
<?php
function FriendlyDayOfWeek($dayNum) {
// converts the sunday to 7
// This function can be removed in php 5 by - date("N"),
// just remove function calls below and replace by swapping date("w" for date("N"
if ($dayNum == 0){ return 7; } else { return $dayNum; }
}
function InsertBlankTd($numberOfTdsToAdd) {
for($i=1;$i<=$numberOfTdsToAdd;$i++) {
$tdString .= "<td></td>";
}
return $tdString;
}
for ($mC=1;$mC<=12;$mC++) {
$currentDT = mktime(0,0,0,$mC,$dDay,$dYear);
echo "<tr><td class='monthName'><div>".date("M",$currentDT)."</div></td>";
$daysInMonth = date("t",$currentDT);
echo InsertBlankTd(FriendlyDayOfWeek(date("w",$currentDT))-1);
for ($i=1;$i<=$daysInMonth;$i++) {
$exactDT = mktime(0,0,0,$mC,$i,$dYear);
if ($i==date("d")&&date("m",$currentDT)==date("m")) { $class="currentDay"; } else { $class = ""; }
echo "<td class='".$class." days day".FriendlyDayOfWeek(date("w",$exactDT))."'>".$i."</td>";
}
echo InsertBlankTd($dDaysOnPage - $daysInMonth - FriendlyDayOfWeek(date("w",$currentDT))+1);
echo "</tr>";
}
?>
</table>