Maison >développement back-end >tutoriel php > 求个PHP列出周日期代码,该怎么解决
求个PHP列出周日期代码
看图片吧,这种列表用PHP怎么写呢?求高人帮帮忙~
<?php<br /> //打印周五<br /> $week = getdate();<br /> //echo $week['wday'];<br /> if($week['wday']==5)<br /> //echo $week['year'].'年'.$week['mon'].'月'.$week['mday'].'日';<br /> //echo $week[year].'年'.$week[mon].'月'.$week[mday].'日';<br /> <br /> for($i=1;$i<=20;$i++)<br /> {<br /> $j=$i*-7;<br /> $k=$j+7;<br /> echo date("Y年m月d日",strtotime($j." days"));<br /> echo "->".date("Y年m月d日",strtotime($k." days"));<br /> echo "<br />";<br /> }<br /> ?>
$s='2013-05-31';<br /> $current=date("Y-m-d");<br /> while($current>=$s){<br /> $ar[]=$current;<br /> $current=date("Y-m-d",strtotime("$current -7 day"));<br /> }<br /> for($i=0;$i<count($ar)-1;$i++){<br /> echo $ar[$i+1].'->'.$ar[$i]."\n";<br /> }
for($i=0,$t=-7; $i<20; $i++,$t-=7) {<br /> echo date('Y-m-d -> ', strtotime("$t day"));<br /> echo date('Y-m-d', strtotime(($t+7)."day")) . '<br>';<br /> }