吃鸡游戏
另一种方法是使用DateTime类,这样你也可以指定时区。注意:PHP 5.3或更高版本。// For the current datefunction isTodayWeekend() {
$currentDate = new DateTime("now", new DateTimeZone("Europe/Amsterdam"));
return $currentDate->format('N') >= 6;}如果您需要能够检查某个日期字符串,则可以使用DateTime :: createFromFormatfunction isWeekend($date) {
$inputDate = DateTime::createFromFormat("d-m-Y", $date, new DateTimeZone("Europe/Amsterdam"));
return $inputDate->format('N') >= 6;}这种方式的优点在于您可以在不改变PHP全局时区的情况下指定时区,这可能会在其他脚本中引起副作用(例如Wordpress)。