欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2024-02-14 11:04:28
...
$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