您的位置:首页网页设计PHP实例 → PHP自动生成月历代码

PHP自动生成月历代码

时间:2004/11/7 3:31:00来源:本站整理作者:蓝点我要评论(0)

<?php
/* 
Function Written by Nelson Neoh @3/2004. 
For those who wants to utilize this code, please do not remove this remark. 
If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board.  Thank you.

 

Function usage: calendar(Month,Year)
*/
   
function calendar($MM,$YYYY){
    if($MM=="") $MM = date("m");
    if($YYYY=="") $YYYY = date("Y");
    if(checkdate($MM,1,$YYYY)){
        $stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY));
        $days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY));
        $firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY));
        $lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY));

        $preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY));
        $preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY));
        $nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY));
        $nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY));
        print("

");
        print("");
        print("");
        print("");
        print("");
        print("");
       
        $currentDays = 1;
        for($a=1;$a<=5;$a++){
            print("");
            $diffDays = $firstDay-$lastDay;
            if($firstDay>$lastDay && $currentDays ==1 && ($diffDays<>1)){
                for($x=$lastDay;$x>=0;$x--){

                    print("");
                }
                for($z=1;$z<$firstDay-$lastDay;$z++){
                    print("");
                }
                for($y=$firstDay;$y<7;$y++){
                    print("");
                    $currentDays++;
                }
            } elseif($firstDay!=0 && $currentDays==1){
                for($z=1;$z<=$firstDay;$z++){
                    print("");
                }
                for($y=$firstDay;$y<7;$y++){
                    print("");
                    $currentDays++;
                }
            } else {
                for($u=1;$u<=7 && $currentDays<=$days;$u++){
                    print("");
                    $currentDays++;
                }
            }
            print("");
        }
        print("

P
".strftime("%b %Y",mktime (0,0,0,$MM,1,$YYYY))."
N




Sun
Mon
Tue
Wed
Thu
Fri
Sat

&nbsp;
$currentDays
&nbsp;
$currentDays
$currentDays

");
    }
}
?>

 

相关阅读 Mac和Windows哪个好 windows和mac os对比介绍Win10预览版怎么升级 Win10预览版升级方法厂商不再预装Win7或8.1系统,驱动人生帮您快速升级Mac移动硬盘安装win8 Mac将win装在移动硬盘使用教程windows10xboxone串流简单教程Windows Hello怎么用 Windows Hello使用设置教程win10怎么关闭自动更新 win10如何关闭自动更新Mac系统如何远程桌面到Windows系统

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 我的php文件怎么打开_php运算符怎么写 php 如何生成静态页面的函数PHP生成图片缩略图PHP session常见问题集锦及解决办法PHP实现同步远程Mysql

人气排行 DEDE在文章列表文章没有缩略图的不显示图片php+mysq修改用户密码我的php文件怎么打开_如何打开php文件的办法FCKeditor的配置和使用方法使用dedecms建站教程PHP+Ajax实现分页技术图片存储与浏览一例Linux+Apache+PHP+MySQLPHP生成图片缩略图