We often have to work with days of the week, and the following code generates a Drop-down list that starts 10 weeks from the current week.

Source: Internet
Author: User
Tags date
Dropdown | Drop-down List For example today is 2000-05-18, the following code generates a 10 week date of the week that begins
Drop-down list.

<?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;//to this week's Saturday
$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] to $day_end[$i] Week </option>";
echo "</select>"
?>



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.