# 我們經常要處理一些以星期為單位的日期，以下的代碼產生一個從當前周開始十個星期的下拉式清單。

<?php
\$t_month=date("m");\$t_day=date("d");\$t_year=date("Y");
while (date("D",mktime(0,0,0,\$t_month,\$t_day,\$t_year))!="Sat")
\$t_day=\$t_day+1;//到本周的星期六
\$end_date=date("Y-m-d",mktime(0,0,0,\$t_month,\$t_day,\$t_year));
\$begin_date=date("Y-m-d",mktime(0,0,0,\$t_month,\$t_day-6,\$t_year));
\$day_begin[]=\$begin_date;
\$day_end[]=\$end_date;
for (\$i=1;\$i<10;\$i++)
{
\$mydate=mktime(0,0,0,\$t_month,\$t_day-7,\$t_year);
\$t_month=date("m",\$mydate);\$t_day=date("d",\$mydate);
\$t_year=date("Y",\$mydate);
\$day_end[]=date("Y-m-d",\$mydate);
\$day_begin[]=date("Y-m-d",mktime(0,0,0,\$t_month,\$t_day-7,\$t_year));
}

echo "  <select name=\"begin_date\">";
for (\$i=0;\$i<10;\$i++)
echo "<option value=\"\$day_begin[\$i]:\$day_end[\$i]\">\$day_begin[\$i]到\$day_end[\$i]的一周</option>";
echo "</select>"
?>

## Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

## Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

## Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth \$300-1200 USD