越简单越好!

算第$w周星期一为几月几日.

发表于 2006-11-22 08:45 | 495次阅读 0次点赞   PHP
<?php
//算第$w周星期一为几月几日.
function w($w,$y){   //$w为第几周;//$y哪一年
 $days = date('w',mktime(0,0,0,1,1,$y));
 if($days==0){
  $a = 24*60*60;
 }else{
  $a = (8-$days)*24*60*60;
 }
 $sec = $w*7*24*60*60+mktime(0,0,0,1,1,$y)+$a-7*24*60*60;
 echo date('Y-m-d',$sec)."<br>";
}
w(2,2007);
?>
返回顶部 ^