function weekday ($theDate){ $year = substr($theDate,0,4); $month = substr($theDate,5,2); $day = substr($theDate,8,2); $lastDays = 0; for ( $i = 1; $i < $month; $i++ ) { $daysOfMonth = 31; switch($i) { case 2 : $daysOfMonth = $year % 4 == 0 ? 29 : 28; break; case 4 : $daysOfMonth = 30; break; case 6 : $daysOfMonth = 30; break; case 9 : $daysOfMonth = 30; break; case 11: $daysOfMonth = 30; break; } $lastDays += $daysOfMonth; } $lastDays += $day; $leapYear = $year / 4; $nonLeapYear = $year - $leapYear; //$theWeekday = ($leapYear * 366 + ($year - ($year / 4)) * 365 + $lastDays - 3) % 7; echo $leapYear; switch($theWeekday) { case 0: $theWeekday = "日"; break; case 1: $theWeekday = "一"; break; case 2: $theWeekday = "二"; break; case 3: $theWeekday = "三"; break; case 4: $theWeekday = "四"; break; case 5: $theWeekday = "五"; break; case 6: $theWeekday = "六"; break; } return $theWeekday; } //echo weekday("2008-06-25"); ?>