04
2025
April
|
||||||
日 | 月 | 火 | 水 | 木 | 金 | 土 |
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
<?php
$d = date_create();
$year = date_format($d, "Y");
$month = date_format($d, "m");
SimpleCalendar($year, $month);
function SimpleCalendar($year, $month){
$ymd = "{$year}/{$month}/1";
$d = date_create($ymd);
$month_f = date_format($d, "F");
echo <<< EOM
<table class="php_cal_simple1">
<tr>
<td colspan="7">
<div class="cale1">
<div class="cale2">{$month}</div>
<div class="cale3">
<div class="cale4">{$year}</div>
<div class="cale4">{$month_f}</div>
</div>
</div>
</td>
</tr>
<tr class="cale5">
<td><span class="cale6">日</span></td>
<td>月</td>
<td>火</td>
<td>水</td>
<td>木</td>
<td>金</td>
<td><span class="cale7">土</span></td>
</tr>
<tr class="cale5">
EOM;
$wd1 = date_format($d, "w");
for($i = 1; $i <= $wd1; $i++){
echo "<td></td>";
}
$day = "1";
while(checkdate($month, $day, $year)){
$date = $year . $month . sprintf('%02d', $day);
$today = date_create();
$today = date_format($today, "Ymd");
$ymd = "{$year}/{$month}/{$day}";
$d = date_create($ymd);
$wd2 = date_format($d, "w");
if($wd2 == "0"){
if($date == $today){
echo "<td class=\"cale8\"><span class=\"cale6\">{$day}</span></td>";
}else{
echo "<td><span class=\"cale6\">{$day}</span></td>";
}
}elseif($wd2 == "6"){
if($date == $today){
echo "<td class=\"cale8\"><span class=\"cale7\">{$day}</span></td>";
}else{
echo "<td><span class=\"cale7\">{$day}</span></td>";
}
echo "</tr>";
if(checkdate($month, $day + 1, $year)){
echo "<tr class=\"cale5\">";
}
}else{
if($date == $today){
echo "<td class=\"cale8\">{$day}</td>";
}else{
echo "<td>{$day}</td>";
}
}
$day++;
}
if($month == "12"){
$month = "0";
$year = $year + 1;
}
$month = $month + 1;
$ymd = "{$year}/{$month}/0";
$d = date_create($ymd);
$wd3 = date_format($d, "w");
$wd4 = 6 - $wd3;
for($i = 1; $i <= $wd4; $i++){
echo "<td></td>";
}
echo "</tr></table>";
}
?>
.php_cal_simple1{
width: 18rem;
}
.php_cal_simple1 .cale1{
display: flex;
align-items: center;
padding: 1rem 0rem;
}
.php_cal_simple1 .cale2{
width: 10rem;
text-align: right;
font-size: 2.5rem;
}
.php_cal_simple1 .cale3{
margin-left: 1rem;
}
.php_cal_simple1 .cale4{
line-height: 1.3rem;
text-align: left;
color: #aaa;
font-size: 0.8rem;
}
.php_cal_simple1 .cale5 td{
height: 3.4rem;
text-align: center;
font-size: 0.8rem;
border: 1px solid #ccc;
}
.php_cal_simple1 .cale5 .cale6{
color: #f00;
}
.php_cal_simple1 .cale5 .cale7{
color: #00f;
}
.php_cal_simple1 .cale5 .cale8{
background-color: #f2f2f2;
}
@media only screen and (min-width: 1024px){
.php_cal_simple1{
width: 30rem;
}
.php_cal_simple1 .cale2{
width: 15.9rem;
font-size: 3rem;
}
.php_cal_simple1 .cale5 td{
height: 4rem;
}
}