欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

PHP日历代码通用函数

程序员文章站 2024-01-09 08:44:22
...
//calendar.php
//Check if the month and year values exist
if ((!$_GET['month']) && (!$_GET['year'])) {
$month = date ("n");
$year = date ("Y");
} else {
$month = $_GET['month'];
$year = $_GET['year'];
}
//Calculate the viewed month
$timestamp = mktime (0, 0, 0, $month, 1, $year);
$monthname = date("F", $timestamp);
//Now let's create the table with the proper month
?>













$monthstart = date("w", $timestamp);
$lastday = date("d", mktime (0, 0, 0, $month + 1, 0, $year));
$startdate = -$monthstart;

//Figure out how many rows we need.
$numrows = ceil (((date("t",mktime (0, 0, 0, $month + 1, 0, $year)) + $monthstart) / 7));

//Let's make an appropriate number of rows...
for ($k = 1; $k ?> //Use 7 columns (for 7 days)...
for ($i = 0; $i $startdate++;
if (($startdate $lastday)){
//If we have a blank day in the calendar.
?> } else {

if ($startdate == date("j") && $month == date("n") && $year == date("Y")){
?> } else {
?> }
}
}
?> }
?>



Su

M

Tu

W

Th

F

Sa
',event);" > ',event);" >



上一篇:

下一篇: