Home > php教程 > php手册 > 我们经常要处理一些以星期为单位的日期,以下的代码生成一个从当前周开始十个星期的下拉列表。

我们经常要处理一些以星期为单位的日期,以下的代码生成一个从当前周开始十个星期的下拉列表。

WBOY
Release: 2016-06-21 09:13:38
Original
1121 people have browsed it

下拉|下拉列表

比方说今天是2000-05-18 ,以下代码生成的是本周开始的十周的日期的一个
下拉列表。

$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 {    
      $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 "  "
?>
     



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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template