Ask for a PHP code to list the week date and see the picture. how can I write this list using PHP? Please help me ~ Share To: ------ the solution asks for a PHP to list the weekly date code
See the picture. how can I write this list in PHP? Please help me ~
Share:
------ Solution --------------------
// Print Friday
$ Week = getdate ();
// Echo $ week ['wday'];
If ($ week ['wday'] = 5)
// Echo $ week ['Year']. 'year'. $ week ['mon']. 'month'. $ week ['mday']. 'day ';
// Echo $ week [year]. 'year'. $ week [mon]. 'month'. $ week [mday]. 'day ';
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"
";
}
?>
The code is rough.
------ Solution --------------------
$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
echo $ar[$i+1].'->'.$ar[$i]."\n";
}
------ Solution --------------------
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")) . '
';
}