-
-
- /*
- * php日历功能
- * edit: bbs.it-home.org
- */
- @date_default_timezone_set('RPC');
function show_calender(){
- $starttime=microtime();
//处理请求日期
- $y= isset($_GET["y"]) ? intval($_GET["y"]) : date("Y");
- $m= isset($_GET["m"]) ? intval($_GET["m"]) : date("m");
- if($m12)$m=date("m");
- if($y
//下个月
- $nm=$m+1;
- if($nm>12){
- $nm=1;
- $ny=$y+1;
- }else{
- $ny=$y;
- }
//前一月
- $pm=$m-1;
- if($pm $pm=12;
- $py=$y-1;
- }else{
- $py=$y;
- }
//获取本月名称
- $month = date("M",mktime(0, 0, 0, $m, 1, $y));
//获取本月最后一天
- $lastday = date("d",mktime(0, 0, 0, $nm, 0, $ny));
//获取开始一天的星期几
- $index = date("w",mktime(0, 0, 0, $m, 1, $y));
//生成日历头
- echo "
\n
- |
{$y} {$month} |
+ |
\n
日 |
一 |
二 |
三 |
四 |
五 |
六 |
"; //处理日历
- $row=0;
- $day=1;
- while(1){
- echo "
";- if($row==0){
- for($i=0;$i if($i echo "
| ";
- else
- echo "
".$day++." | ";
- }else{
- for($i=0;$i if($day>$lastday)
- echo "
| ";
- else
- echo "
".$day++." | ";
- }
- echo "
";
- $row++;
- if($day>$lastday)break;
- }
- echo "
";
$endtime=microtime();
- $usedtime=$endtime-$starttime;
- return $usedtime;
- }
$run_info=array();
- for($i=0;$i $run_info[]=show_calender();
print_r($run_info);
- ?>
-
复制代码
测试结果:
Array
(
[0] => 0.00038400000000005
[1] => 0.00030999999999998
[2] => 0.00029699999999999
[3] => 0.000303
[4] => 0.00030399999999997
[5] => 0.00034499999999998
[6] => 0.00032300000000002
[7] => 0.00033
[8] => 0.00032699999999997
[9] => 0.00032000000000004
)
>>> 您可能感兴趣的文章:
php calender日历代码(解决2038问题)
php日历代码(附演示效果)
php日历代码分享 简单实用的php日历代码
php日历代码 三个不错的php日历代码
分享一例PHP简单日历代码
php简单日历的实现代码(可绑定事件)
|