Home > Backend Development > PHP Tutorial > 求个PHP列出周日期代码

求个PHP列出周日期代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:24:00
Original
885 people have browsed it



看图片吧,这种列表用PHP怎么写呢?求高人帮帮忙~


回复讨论(解决方案)

<?php//打印周五$week = getdate();//echo $week['wday'];if($week['wday']==5)//echo $week['year'].'年'.$week['mon'].'月'.$week['mday'].'日';//echo $week[year].'年'.$week[mon].'月'.$week[mday].'日';for($i=1;$i<=20;$i++){$j=$i*-7;$k=$j+7;echo date("Y年m月d日",strtotime($j." days"));echo "->".date("Y年m月d日",strtotime($k." days"));echo "<br />";}?>
Copy after login


代码写得很粗糙

$s='2013-05-31';$current=date("Y-m-d");while($current>=$s){    $ar[]=$current;	$current=date("Y-m-d",strtotime("$current -7 day"));}	for($i=0;$i<count($ar)-1;$i++){	   echo $ar[$i+1].'->'.$ar[$i]."\n";	}
Copy after login

for($i=0,$t=-7; $i<20; $i++,$t-=7) {  echo date('Y-m-d -> ', strtotime("$t day"));  echo date('Y-m-d', strtotime(($t+7)."day")) . '<br>';}
Copy after login
Copy after login

谢谢各位啦...

for($i=0,$t=-7; $i<20; $i++,$t-=7) {  echo date('Y-m-d -> ', strtotime("$t day"));  echo date('Y-m-d', strtotime(($t+7)."day")) . '<br>';}
Copy after login
Copy after login

!~

Related labels:
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