本文最后更新于468天前,其中的信息可能已经过时,如有错误请在评论区悄悄告诉我~~~
通过传入日期,计算那是星期几并输出(因为没有做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}";
?>