Ask for PHP to list weekend code

Source: Internet
Author: User
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")) . '
';
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.