DDR爱好者之家 Design By 杰米
比较不错的一款php日历代码
复制代码 代码如下:
<?php
/**
* 日历
*
* Copyright(c) 2007 by 陈毅鑫(深空). All rights reserved
* To contact the author write to {@link mailto:shenkong@php.net}
* @author 陈毅鑫(深空)
*/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($date));
$end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '<table border="1">';
$html .= '<tr>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $pre . '">-</a></td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $next . '">+</a></td>';
$html .= '</tr>';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td><b>' . $v . '</b></td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>
php日历代码2
复制代码 代码如下:
<?php
/**
* 日历
*/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($date));
$end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '<table width="200" border="1" cellspacing="0" bordercolor="#999999"
align="center" style="line-height:150%; font-family:Verdana,宋体; font-size: 12px;">';
$html .= '<tr>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $pre . '">-</a></td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $next . '">+</a></td>';
$html .= '</tr>';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td><b>' . $v . '</b></td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>"codetitle">复制代码 代码如下:
<?php
function calendar()
{
if($_GET['ym'])
{
$year = substr($_GET['ym'],0,4);
$month = substr($_GET['ym'],4,(strlen($_GET['ym'])-4));
if($month>12)
{
$year += floor($month/12);
$month = $month % 12;
}
if($year > 2030) $year = 2030;
if($year < 1980) $year = 1980;
}
$year = isset($year) ? $year : date('Y');
$month = isset($month) ? $month : date('n');
if($year==date('Y') && $month==date('n')) $today = date('j');
if($month-1 == 0)
$prevmonth = ($year - 1)."12";
else $prevmonth = $year.($month - 1);
if($month+1 == 13)
$nextmonth = ($year+1)."1";
else $nextmonth = $year.($month+1);
$prevyear = ($year - 1).$month;
$nextyear = ($year + 1).$month;
echo <<<VKN
<table width="200" border="0" cellpadding="2" cellspacing="2">
<tr>
<td class="weekday"><a href="?ym=$prevyear"><<</a></td>
<td class="normalday"><a href="?ym=$prevmonth"><</a></td>
<td colspan="3" class="normalday">$year - $month</td>
<td class="normalday"><a href="?ym=$nextmonth"</a></td>
<td class="weekday"><a href="?ym=$nextyear"></a></td>
</tr>
<tr>
<td width="27" class="weekday">日</td>
<td width="27" class="normalday">一</td>
<td width="27" class="normalday">二</td>
<td width="27" class="normalday">三</td>
<td width="27" class="normalday">四</td>
<td width="27" class="normalday">五</td>
<td width="27" class="weekday">六</td>
</tr>
VKN;
$nowtime = mktime(0,0,0,$month,1,$year);//当月1号转为秒
$daysofmonth = date(t,$nowtime);//当月天数
$weekofbeginday = date(w,$nowtime);//当月第一天是星期几
$weekofendday = date(w,mktime(0,0,0,$month+1,0,$year));//当月最后一天是星期几
$daysofprevmonth = date(t,mktime(0,0,0,$month,0,$year));//上个月天数
$count = 1;//计数
//列出上月后几天
for($i = 1 ; $i <= $weekofbeginday ; $i++)
{
echo "<td class='othermonth'>".($daysofprevmonth-$weekofbeginday+$i)."</td>";
$count++;
}
//当月全部
for($i = 1 ; $i <= $daysofmonth ; $i++)
{
$css = ($count%7==0 || $count%7==1)?"weekday":"normalday";
if($i == $today) $css .= "today";
echo "<td class='".$css."'>".$i."</td>";
if($count%7==0) echo "</tr><tr>";
$count++;
}
//下月前几天
for ($i = 1;$i <= 6-$weekofendday;$i++)
{
echo "<td class='othermonth'>".$i."</td>";
}
echo <<<VKN
<tr>
<td colspan="7"></td>
</tr>
</table>
VKN;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>calendar</title>
<style type="text/css">
<!--
.weekday {
font-size: 9pt;
color: #FF0000;
text-align: center;
}
.normalday {
font-size: 9pt;
color: #000000;
text-align: center;
}
.weekdaytoday {
font-size: 9pt;
color: #FF0000;
text-align: center;
background-color: #FFD9D9;
font-weight: bold;
}
.normaldaytoday {
font-size: 9pt;
color: #000000;
text-align: center;
background-color: #DDDDDD;
font-weight: bold;
}
.othermonth {
font-size: 9pt;
font-style: italic;
color: #999999;
text-align: center;
}
-->
</style>
</head>
<body>
<?php calendar();?>
</body>
</html>
复制代码 代码如下:
<?php
/**
* 日历
*
* Copyright(c) 2007 by 陈毅鑫(深空). All rights reserved
* To contact the author write to {@link mailto:shenkong@php.net}
* @author 陈毅鑫(深空)
*/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($date));
$end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '<table border="1">';
$html .= '<tr>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $pre . '">-</a></td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $next . '">+</a></td>';
$html .= '</tr>';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td><b>' . $v . '</b></td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>
php日历代码2
复制代码 代码如下:
<?php
/**
* 日历
*/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($date));
$end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '<table width="200" border="1" cellspacing="0" bordercolor="#999999"
align="center" style="line-height:150%; font-family:Verdana,宋体; font-size: 12px;">';
$html .= '<tr>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $pre . '">-</a></td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $PHP_SELF . '?date=' . $next . '">+</a></td>';
$html .= '</tr>';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td><b>' . $v . '</b></td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>"codetitle">复制代码 代码如下:
<?php
function calendar()
{
if($_GET['ym'])
{
$year = substr($_GET['ym'],0,4);
$month = substr($_GET['ym'],4,(strlen($_GET['ym'])-4));
if($month>12)
{
$year += floor($month/12);
$month = $month % 12;
}
if($year > 2030) $year = 2030;
if($year < 1980) $year = 1980;
}
$year = isset($year) ? $year : date('Y');
$month = isset($month) ? $month : date('n');
if($year==date('Y') && $month==date('n')) $today = date('j');
if($month-1 == 0)
$prevmonth = ($year - 1)."12";
else $prevmonth = $year.($month - 1);
if($month+1 == 13)
$nextmonth = ($year+1)."1";
else $nextmonth = $year.($month+1);
$prevyear = ($year - 1).$month;
$nextyear = ($year + 1).$month;
echo <<<VKN
<table width="200" border="0" cellpadding="2" cellspacing="2">
<tr>
<td class="weekday"><a href="?ym=$prevyear"><<</a></td>
<td class="normalday"><a href="?ym=$prevmonth"><</a></td>
<td colspan="3" class="normalday">$year - $month</td>
<td class="normalday"><a href="?ym=$nextmonth"</a></td>
<td class="weekday"><a href="?ym=$nextyear"></a></td>
</tr>
<tr>
<td width="27" class="weekday">日</td>
<td width="27" class="normalday">一</td>
<td width="27" class="normalday">二</td>
<td width="27" class="normalday">三</td>
<td width="27" class="normalday">四</td>
<td width="27" class="normalday">五</td>
<td width="27" class="weekday">六</td>
</tr>
VKN;
$nowtime = mktime(0,0,0,$month,1,$year);//当月1号转为秒
$daysofmonth = date(t,$nowtime);//当月天数
$weekofbeginday = date(w,$nowtime);//当月第一天是星期几
$weekofendday = date(w,mktime(0,0,0,$month+1,0,$year));//当月最后一天是星期几
$daysofprevmonth = date(t,mktime(0,0,0,$month,0,$year));//上个月天数
$count = 1;//计数
//列出上月后几天
for($i = 1 ; $i <= $weekofbeginday ; $i++)
{
echo "<td class='othermonth'>".($daysofprevmonth-$weekofbeginday+$i)."</td>";
$count++;
}
//当月全部
for($i = 1 ; $i <= $daysofmonth ; $i++)
{
$css = ($count%7==0 || $count%7==1)?"weekday":"normalday";
if($i == $today) $css .= "today";
echo "<td class='".$css."'>".$i."</td>";
if($count%7==0) echo "</tr><tr>";
$count++;
}
//下月前几天
for ($i = 1;$i <= 6-$weekofendday;$i++)
{
echo "<td class='othermonth'>".$i."</td>";
}
echo <<<VKN
<tr>
<td colspan="7"></td>
</tr>
</table>
VKN;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>calendar</title>
<style type="text/css">
<!--
.weekday {
font-size: 9pt;
color: #FF0000;
text-align: center;
}
.normalday {
font-size: 9pt;
color: #000000;
text-align: center;
}
.weekdaytoday {
font-size: 9pt;
color: #FF0000;
text-align: center;
background-color: #FFD9D9;
font-weight: bold;
}
.normaldaytoday {
font-size: 9pt;
color: #000000;
text-align: center;
background-color: #DDDDDD;
font-weight: bold;
}
.othermonth {
font-size: 9pt;
font-style: italic;
color: #999999;
text-align: center;
}
-->
</style>
</head>
<body>
<?php calendar();?>
</body>
</html>
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年11月25日
2024年11月25日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]