週の最初の列の最初の日を日曜日に変更するにはどうすればよいですか?
ここに私がウェブサイトから入手したコードがあります。私は日の位置を変更しようとしましたが、それでも週の最初の日を月曜日として表示します。どうすれば日曜日に変更できますか、よろしくお願いします:)
<?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>