搜索
首页php教程php手册php日历[测试通过]

php日历[测试通过]

Jun 13, 2016 pm 12:29 PM
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 = '

';
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $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 .= '';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '';
} else {
$html .= '';
}
} else {
$html .= '';
}
}
$html .= '';
}
$html .= '
-' . $date['year'] . ';' . $date['month'] . '+
' . $v . '' . $v . ' 
';
echo $html;
?>

php日历代码2

复制代码 代码如下:


/**
* 日历
*/
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 = '

align="center" style="line-height:150%; font-family:Verdana,宋体; font-size: 12px;">';
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $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 .= '';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '';
} else {
$html .= '';
}
} else {
$html .= '';
}
}
$html .= '';
}
$html .= '
-' . $date['year'] . ';' . $date['month'] . '+
' . $v . '' . $v . '
';
echo $html;
?>

下面这个也不错,提示有错误,思路清晰

复制代码 代码如下:


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         


  
    
    
    
    
    
  
  
    
    
    
    
    
    
    
  
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         {
            echo     "";
            $count++;
        }
    //当月全部
    for($i = 1 ; $i         {
            $css = ($count%7==0 || $count%7==1)?"weekday":"normalday";
            if($i == $today) $css .= "today";

            echo     "";
            if($count%7==0) echo "";
            $count++;
        }
    //下月前几天
    for ($i = 1;$i         {
            echo     "";
        }

    echo           
    
  
$year - $month > >>
".($daysofprevmonth-$weekofbeginday+$i)."".$i."
".$i."

VKN;
}
?>
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



calendar







声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境