首页 > php date('W')是否可逆

php date('W')是否可逆

求一个

$week = date('W');

function($year,$week) return 星期一的时间;

同时求解

date("W",strtotime('2011-1-1')) 为何 不是 1

date("W",strtotime('2013-1-1')) 为何是 1


W是显示第几周,从星期一开始的说。2011年1月1号是礼拜六,不算是第1周的说,2013年1月1号是礼拜二,当然是第1周啦~

另外,你想要返回某一周的礼拜一直接用

<?php
$year = 2013;
$week = '02';
echo strtotime($year.'-W'.$week.'-1');
?>

就可以了,具体可以看看strtotime,官方手册上有详细说明

【热门文章】
【热门文章】