vivo手机怎么制作主题:[PHP]知道星期怎么得到日期呀

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 00:52:03
例如这个星期是今年的第8orX周,怎么算出本周的起始日期呢,要代码哦,谢谢!
得人指点已经有答案了:
function getDateListByWeek($year, $week)
{
$year = (int)$year;
$week = (int)$week;
$microtime = mktime(0,0,0,1,1+$week*7,$year);
$order = date('w',$microtime);
$info = array();

$info['start'] = mktime(0,0,0,date("m",$microtime),date("d", $microtime)-($order-1),date("Y",$microtime));

if(date('W',$info['start']) != $week)
{
$microtime = mktime(0,0,0,
date("m",$microtime),
date("d", $microtime)-(date('W',$info['start'])-$week)*7,
date("Y",$microtime));
$info['start'] = date("Ymd",mktime(0,0,0,date("m",$microtime),date("d", $microtime)-($order-1),date("Y",$microtime)));
}

$info['end'] = date("Ymd",mktime(23,59,59,date("m",$microtime),date("d", $microtime)+(5-$order),date("Y",$microtime)));

return $info;
}

$today = getdate();
localtime(time() - 24*60*60*(6 - $today[wday]));
大致意思