PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » PHP资源共享 » PHP自动生成月历代码
本页主题: PHP自动生成月历代码 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

游子云



该用户目前不在线
级别: 管理员
精华: 3
发帖: 246
威望: 205 点
金钱: 2066 PYMB
贡献值: 0 点
在线时间:38(小时)
注册时间:2005-10-27
最后登录:2008-08-19

PHP自动生成月历代码


顶端 Posted: 2005-12-23 13:17 | [楼 主]
游子云



该用户目前不在线
级别: 管理员
精华: 3
发帖: 246
威望: 205 点
金钱: 2066 PYMB
贡献值: 0 点
在线时间:38(小时)
注册时间:2005-10-27
最后登录:2008-08-19

PHP自动生成月历代码


[code]/*
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));
$printDays = $days;
$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--){
$printDays = $days-$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
SunMonTueWedThuFriSat
$printDays $currentDays $currentDays$currentDays
");
}
}
?>

[/code]
顶端 Posted: 2005-12-23 13:17 | 1 楼
ok888ok



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 10
威望: 11 点
金钱: 100 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2006-08-31
最后登录:2006-08-31


路过顶一下。。。
顶端 Posted: 2006-08-31 23:19 | 2 楼
yhl_amerry



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 1
威望: 2 点
金钱: 10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2006-09-19
最后登录:2006-11-12


谢谢楼主
顶端 Posted: 2006-10-16 16:34 | 3 楼
dahiao

该用户目前不在线
级别: 新手上路
精华: 0
发帖: 2
威望: 3 点
金钱: 20 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2007-06-05
最后登录:2007-06-05


这下找学习PHP的老师了,哈哈,请多多联系,QQ297542491
msn:shirongyong@163.com
顶端 Posted: 2007-06-05 13:53 | 4 楼
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » PHP资源共享

现在时间:09-08 13:41 Copyright © 2006 phpwhy.com 版权所有
浙ICP备05060669号

点击这里给我发消息关于我们 - 合作联系