Ask PHP to list the Sunday period code
Look at the picture, how do you write this list in PHP? Ask Gao to help ~
Share to:
------Solution--------------------
Print Friday
$week = getdate ();
echo $week [' wday '];
if ($week [' Wday ']==5)
echo $week [' Year ']. ' Years '. $week [' mon ']. ' Month '. $week [' Mday ']. ' Day ';
Echo $week [year]. ' Years '. $week [mon]. ' Month '. $week [mday]. ' Day ';
for ($i =1; $i <=20; $i + +)
{
$j = $i *-7;
$k = $j +7;
echo Date ("Y year M D Day", Strtotime ($j. "Days"));
echo ". Date (" Y year M D Day ", Strtotime ($k." Days "));
echo "
";
}
?>
The code is very 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 ")). '
';
}