Home > Backend Development > PHP Tutorial > 中邪了吗?怎么都是星期四

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

WBOY
Release: 2016-06-23 13:13:19
Original
976 people have browsed it

<?$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")];
Copy after login

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


回复讨论(解决方案)

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



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template