We often need to process some dates in the unit of weeks. The following code generates
Source: Internet
Author: User
For example, today is. the following code generates a drop-down list of the dates of the first 10 weeks of this week .? Php $ t_monthdate (m); $ t_daydate (d); $ t_yeardate (Y); while (date (D, mktime (0, 0, 0, $ t_month, $ t_day, $ t_year ))! Sat) $ t_day for example, today is. the following code generates a date for the first 10 weeks of this week.
Drop-down list.
$ T_month = date ("m"); $ t_day = date ("d"); $ t_year = date ("Y ");
While (date ("D", mktime (0, 0, $ t_month, $ t_day, $ t_year ))! = "Sat ")
$ T_day = $ t_day + 1; // until Saturday of the week
$ End_date = date ("Y-m-d", mktime (0, 0, $ t_month, $ t_day, $ t_year ));
$ Begin_date = date ("Y-m-d", mktime (, 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, $ 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, $ t_month, $ t_day-7, $ t_year ));
}
Echo" ";For ($ I = 0; $ I <10; $ I ++)Echo"$ Day_begin [$ I] to $ day_end [$ I] week";Echo""
?>
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.