通过传入日期,计算那是星期几并输出(因为没有做HTML页面,所以这里用变量代替传入)
<?php
$year = 2023;
$month = 9;
$day = 19;
$week = date("w", mktime(0, 0, 0, $month, $day, $year));
switch($week){
case 0:
$weeks = "日";
break;
case 1:
$weeks = "一";
break;
case 2:
$weeks = "二";
break;
case 3:
$weeks = "三";
break;
case 4:
$weeks = "四";
break;
case 5:
$weeks = "五";
break;
case 6:
$weeks = "六";
break;
}
echo "{$year}年{$month}月{$day}日是星期{$weeks}";
?>
作者:404_502
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0协议。转载请注明文章地址及作者