首頁 >後端開發 >php教程 >中邪了吗?怎么都是星期四

中邪了吗?怎么都是星期四

WBOY
WBOY原創
2016-06-23 13:13:19972瀏覽

<?$weekarray=array("日","一","二","三","四","五","六");$windex = date("N",'2016-03-18 17:30:01');$ww = $weekarray[$windex];echo $ww;$windex = date("N",'2016-03-19 17:30:01');$ww = $weekarray[$windex];echo $ww;$windex = date("N",'2016-03-20 17:30:01');$ww = $weekarray[$windex];echo $ww;$weekarray=array("日","一","二","三","四","五","六");echo "星期".$weekarray[date("w","2011-11-12")];

?>
我这里的输出是:
四四四星期四


回复讨论(解决方案)

PHP Version 5.5.9

$windex = date("N", '2016-03-18 17:30:01');
PHP 5.5.9 的 date 能接受这样的参数吗?
不需要 strtotime 转换?
'1970-01-01  就是星期四,您可以去查一下万年历

date("N") 得到的范围是 1~7,星期日为 7
date("w") 得到的范围是 0~6,星期日为 0



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn