比较不错的一款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 = '
- | ';' . $date['year'] . ';' . $date['month'] . ' | ';+ | ';||||
' . $v . ' | ';' . $v . ' | ';'; |
复制代码 代码如下:
/**
* 日历
*/
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 = '
- | ';' . $date['year'] . ';' . $date['month'] . ' | ';+ | ';||||
' . $v . ' | ';' . $v . ' | ';'; |
复制代码 代码如下:
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 }
$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
$year - $month | > | >> | ||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | ".($daysofprevmonth-$weekofbeginday+$i)." | ";".$i." | ";
".$i." | ";||||||