Two php date control instances and php date instances. Two php date control instances: php date control instances this article describes two php date control classes. Share it with you for your reference. The specific analysis is as follows: I have found two php date control instances and php date instances for my work.
This example describes two php date control classes. Share it with you for your reference. The specific analysis is as follows:
Because I have to find two time and date controls for my work, I don't need to implement js as long as php is used, because I want to refer to the query operations. if you are interested, please refer to them, I used the second one myself, so the second one was modified.
Example 1: The code is as follows:
The code is as follows:
<? Php
Class Calendar
{
Var $ month;
Var $ year;
Function _ construct ($ year, $ month)
{
$ This-> year = $ year;
$ This-> month = $ month;
}
Function endday ()
{
$ Daydate = date ("d", mktime (0, 0, 0, $ this-> month, 35, $ this-> year ));
$ Endday = 35-$ daydate;
Return $ endday;
}
Function oneday_week ()
{
$ Oneday_week = date ("w", mktime (0, 0, 0, $ this-> month, 1, $ this-> year ));
Return $ oneday_week;
}
Function title_link ()
{
If (! Isset ($ this-> month )&&! Isset ($ this-> year ))
{
$ This-> year = date ("Y ");
$ This-> month = date ("m ");
}
$ Lastmonth = $ this-> month-1;
$ Nextmonth = $ this-> month + 1;
$ Lastyear = $ this-> year;
$ Nextyear = $ this-> year;
If ($ this-> month <= 1)
{
$ Lastmonth = 12;
$ Nextmonth = $ this-> month + 1;
$ Lastyear = $ this-> year-1;
$ Nextyear = $ this-> year;
}
Elseif ($ this-> month> = 12)
{
$ Lastmonth = $ this-> month-1;
$ Nextmonth = 1;
$ Lastyear = $ this-> year;
$ Nextyear = $ this-> year + 1;
}
$ Str ="
<
";
$ Str. ="
". $ This-> year." -- ". $ this-> month ."
";
$ Str. ="
>>>
";
Return $ str;
}
Function Show_Calendar ()
{
Echo"
". $ This-> title_link ()."
";$ Weekarray = array ("day", "one", "two", "three", "four", "five", "six "); For ($ k = 0; $ k <= 6; $ k ++){Echo"
". $ Weekarray [$ k]." | ";}Echo"
"; For ($ I = 0; $ I <= 5; $ I ++){Echo"
";For ($ j = 1; $ j <= 7; $ j ++){$ Math = ($ j-$ this-> oneday_week () + 7 * $ I; Echo"
"; If ($ math <= $ this-> endday () and $ math> = 1) { Echo $ math; } Echo" | ";}Echo"
";}Echo"
";
}
}
$ Calendar = new Calendar ($ _ GET ['Year'], $ _ GET ['month']);
$ Calendar-> month = $ _ GET ['month'];
$ Calendar-> year = $ _ GET ['Year'];
$ Calendar-> Show_Calendar ();
?>
Example 2: The code is as follows:
The code is as follows:
<? Php
Header ("content-type: text/html; charset = utf-8 ");
?>
<? Php
If (! Emptyempty ($ _ GET )){
$ Year = isset ($ _ GET ['Year'])? $ _ GET ['Year']: date ('Y ');
$ Month = isset ($ _ GET ['month'])? $ _ GET ['month']: date ('M ');
$ Day = isset ($ _ GET ['day'])? $ _ GET ['day']: date ('D ');
}
If (emptyempty ($ year )){
$ Year = date ('Y ');
}
If (emptyempty ($ month )){
$ Month = date ('M ');
}
If (emptyempty ($ month )){
$ Days = date ('D ');
}
$ Start_weekday = date ('W', mktime (0, 0, 0, $ month, 1, $ year ));
// Echo $ start_weekday;
$ Days = date ('t', mktime (0, 0, 0, $ month, 1, $ year ));
// Echo $ days;
$ Week = array ('day', 'yi', '2', '3', '4', '5', '6 ');
$ I = 0;
$ K = 1;
$ J = 0;
Echo'
';Echo'
'. $ Year. 'year'. $ month. 'month '.' |
';Echo'
';For ($ I = 0; $ I <7; $ I ++ ){Echo'
'. $ Week [$ I].' | ';}Echo'
';Echo'
';For ($ j = 0; $ j <$ start_weekday; $ j ++ ){Echo'
'. $ J .' | ';}While ($ k <= $ days ){If ($ k = $ day ){Echo'
'. $ K .' | ';} Else {Echo'
'. $ K .' | ';}If ($ j + 1) % 7 = 0 ){Echo'
';}$ J ++;$ K ++;}While ($ j % 7! = 0 ){Echo'
'. $ J .' | ';$ J ++;}Echo'
'; Echo'
';Echo"
". '<'.' | ';Echo"
". '<'.' | ';Echo'
'; Echo ''; Echo' | ';Echo"
". '> '.' | ';Echo"
". '> '.' | ';Echo'
';Echo'
';
Function lastYear ($ year, $ month ){
$ Year = $ year-1;
Return "year = $ year & month = $ month ";
}
Function lastMonth ($ year, $ month ){
If ($ month = 1 ){
$ Year = $ year-1;
$ Month = 12;
} Else {
$ Month --;
}
Return "year = $ year & month = $ month ";
}
Function nextYear ($ year, $ month ){
$ Year = $ year + 1;
Return "year = $ year & month = $ month ";
}
Function nextMonth ($ year, $ month ){
If ($ month = 12 ){
$ Year = $ year + 1;
$ Month = 1;
} Else {
$ Month ++;
}
Return "year = $ year & month = $ month ";
}
?>
I hope this article will help you with php programming.
The example in this article describes two php date control classes. Share it with you for your reference. The specific analysis is as follows: I need to find the job...