分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

php日历

发布时间:2023-09-06 01:22责任编辑:彭小芳关键词:暂无标签
<?php/** ?* 日历 */if (function_exists(‘date_default_timezone_set‘)) { ???date_default_timezone_set(‘Asia/Hong_Kong‘);}$date = isset($_GET[‘date‘]) ? $_GET[‘date‘] : date(‘Y-m-d‘);$date = getdate(strtotime($date));$month_cn = array( ???‘January‘ => ‘01‘, ???‘February‘ => ‘02‘, ???‘March‘ => ‘03‘, ???‘April‘ => ‘04‘, ???‘May‘ => ‘05‘, ???‘June‘ => ‘06‘, ???‘July‘ => ‘07‘, ???‘August‘ => ‘08‘, ???‘September‘ => ‘09‘, ???‘October‘ => ‘10‘, ???‘November‘ => ‘11‘, ???‘December‘ => ‘12‘,);$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);$PHP_SELF = $_SERVER[‘PHP_SELF‘];$html = ‘<table style="border-collapse:collapse;border-spacing:0;line-height:30px; font-family:Verdana,宋体;font-size:12px;width:300px;border:1px solid #aaa" border=1>‘;$html.= ‘<tr align=center>‘;$html.= ‘<td><a href="‘ . $PHP_SELF . ‘?date=‘ . $pre . ‘" style="text-decoration:none"><</a></td>‘;$html.= ‘<td colspan=5>‘ . $date[‘year‘] . ‘ - ‘ . $month_cn[$date[‘month‘]] . ‘<a href="‘ . $PHP_SELF . ‘">今天</a></td>‘;$html.= ‘<td><a href="‘ . $PHP_SELF . ‘?date=‘ . $next . ‘" style="text-decoration:none">></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++; ???}}$html.= " ???<tr align=center style=‘background:#eee‘> ???????<td>一</td> ???????<td>二</td> ???????<td>三</td> ???????<td>四</td> ???????<td>五</td> ???????<td>六</td> ???????<td>日</td> ???</tr>";foreach ($date_arr as $value) { ???$html.= ‘<tr align=center>‘; ???foreach ($value as $v) { ???????if ($v) { ???????????if ($month_cn[$date[‘month‘]] == date(‘m‘) && $v == date(‘d‘)) { ???????????????$html.= ‘<td style="background:#FFC993"><span style="color:#f00;font-weight:bold">‘ . $v . ‘</span></td>‘; ???????????} else { ???????????????$html.= ‘<td>‘ . $v . ‘</td>‘; ???????????} ???????} else { ???????????$html.= ‘<td> </td>‘; ???????} ???} ???$html.= ‘</tr>‘;}$html.= ‘</table>‘;echo $html;?>



;

php日历

原文地址:http://www.cnblogs.com/upup2015/p/7782627.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved