谁有日历源代码方式显示可以点选的日期代码。PHP代码

当前位置: >
php根据日期获取当月的第一天和最后一天
发布时间: 点击次数:正在加载... 来源:
php的日期函数还算完整,今天分享个php的获取第一天和最后一天的函数的代码,输入一个日期,返回第一天和最后一天,利用这个函数配合着日历插件,可以做出一个很好的日程管理。或者活动日历的代码来,希望对你有用!
function&getthemonth($date)&{&&&&&$firstday&=&date('Y-m-01',&strtotime($date));&&&&&$lastday&=&date('Y-m-d',&strtotime(&$firstday&+1&month&-1&day&));&&&&&return&array($firstday,&$lastday);&}&
转载请注明: >>
本文原地址:
也许你会喜欢和关注与本文内容高度相关的文章:
下一篇:没有了
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)php日历代码 - 为程序员服务
为程序员服务
php日历代码
################
# Calendar.php - 创建一个当天日期为高亮度的日历GIF图片。
# 使用到了GD 函数库存和TTF字体 -可以被改变成 PNG格式的图片, 当然,如果
# 你想要的是一个拥有一个透明背景的图片除外,这个改动是可以被很容易得
# 完成,最后,我们把图片写到一个叫 dategif/ 的目录,并且用当天的日期来
# 命名该图片的名字。(如:.gif)这个GIF图片一般情况只会有5K或
# 是7K的大小。
# 这段程序你可以以任意地方使用,该文档或支持对每个人都是免费的,但是请
# 不要把该程序用于买卖,你可以剪切、拷贝或是毁坏这段程序,只要你喜欢,
# 并且,你不用为了用它而给我付费!如果你需要帮助或是你真的很喜欢这段程
# 序,请给我来封信,以让我知道,你看好吗?
# 二月四日4, 2000 由
Matt Florell (
################
&Content-type: image/gif&);
#创建一幅图片
$im = ImageCreate(156, 142);
# 设置颜色
$black = ImageColorAllocate($im, 50, 50, 50);
$white = ImageColorAllocate($im, 255, 255, 255);
$orange = ImageColorAllocate($im, 255, 200, 0);
$yellow = ImageColorAllocate($im, 255, 255, 0);
$tan = ImageColorAllocate($im, 255, 255, 190);
$grey = ImageColorAllocate($im, 205, 205, 205);
$dkgrey = ImageColorAllocate($im, 140, 140, 140);
###灰线 ###
ImageRectangle($im, 1, 1, 155, 141, $dkgrey);
ImageRectangle($im, 1, 22, 155, 39, $dkgrey);
ImageRectangle($im, 1, 56, 155, 73, $dkgrey);
ImageRectangle($im, 1, 90, 155, 107, $dkgrey);
ImageRectangle($im, 1, 107, 155, 124, $dkgrey);
ImageRectangle($im, 23, 22, 45, 141, $dkgrey);
ImageRectangle($im, 67, 22, 89, 141, $dkgrey);
ImageRectangle($im, 111, 22, 133, 141, $dkgrey);
### 白线 ###
ImageRectangle($im, 0, 0, 154, 140, $white);
ImageRectangle($im, 0, 21, 154, 38, $white);
ImageRectangle($im, 0, 55, 154, 72, $white);
ImageRectangle($im, 0, 89, 154, 106, $white);
ImageRectangle($im, 0, 106, 154, 123, $white);
ImageRectangle($im, 22, 21, 44, 140, $white);
ImageRectangle($im, 66, 21, 88, 140, $white);
ImageRectangle($im, 110, 21, 132, 140, $white);
### 在上面写数字
$today = date( &d&);
$month = date( &m&);
$year = date( &Y&);
$datecode = date( &Ymd&);
$first=mktime(0,0,0,$month,1,$year);
$mon_yr=date( &F Y&, $first);
$wd=date( &w&,$first);
#if ($wd==0) { $wd=7;}
$lastday=date( &d&,mktime(0,0,0,$month+1,0,$year));
$cur=-$wd+0;
$ver_position = 50;
for ($k=0;$k&6;$k++) {
$day_position = 5;
$last_row_used = 0;
for ($i=0;$i&7;$i++ ) {
$sing_add = 0;
if (($cur&=0) || ($cur&$lastday) ) $day_position = ($day_position + 22);
$day_color = $
if ($day_position&10) $day_color = $
if ($cur==$today) $day_color = $
if (strlen($cur)&2) {$sing_add = 4;}
$fin_position = ($day_position + $sing_add);
ImageTTFText($im, 12, 0, $fin_position, $ver_position, $day_color,
&./fonts/arialbd.ttf&,
$day_position = ($day_position + 22);
$last_row_used = 1;
$day_position = 5;
if ($last_row_used) $ver_position = ($ver_position + 17);
# 月份和年份 (Arial字体、加粗、居中)
$spc = 23;
$st_add = 0;
&$mon_yr&;
$st_len = strlen($st);
$st_margin = (14 - $st_len);
if ($st_margin & 0) {$st_add = ($st_margin * 4);}
$spc = ($spc + $st_add);
ImageTTFText($im, 14, 0, $spc, 15, $white,
&./fonts/arialbd.ttf&,
# 星期的名字
ImageString($im, 2, 3, 23,
&Sun&, $orange);
ImageString($im, 2, 25, 23,
&Mon&, $orange);
ImageString($im, 2, 47, 23,
&Tue&, $orange);
ImageString($im, 2, 69, 23,
&Wed&, $orange);
ImageString($im, 2, 91, 23,
&Thu&, $orange);
ImageString($im, 2, 113, 23,
&Fri&, $orange);
ImageString($im, 2, 135, 23,
&Sat&, $orange);
if ($ver_position&140)
$im_out = ImageCreate(156, 125);
$out_black = ImageColorAllocate($im_out, 50, 50, 50);
ImageRectangle($im, 1, 124, 155, 124, $dkgrey);
ImageCopyResized($im_out, $im, 0, 0, 0, 0, 156, 125, 156, 125);
ImageColorTransparent($im_out, $out_black);
ImageGIF($im_out,
&./dategif/$datecode$gif&);
ImageGIF($im_out);
ImageDestroy($im);
ImageDestroy($im_out);
ImageColorTransparent($im, $black);
ImageGif($im,
&./dategif/$datecode$gif&);
ImageGif($im);
ImageDestroy($im);
您可能的代码
相关聚客文章
相关专栏文章当前位置:&&
本页文章导读:
&&&&?PHP阴历转农历的实现代码&&&&&&先来个科谱知识:
农历又叫阴历是以月亮绕地球一周的时间为一个月,也就是29天12小时44分3秒,它一年十二个月为354天。
阳历也称为公历,它是以地球绕太阳一周的时间十二个月为一年也......&&&&?php日历代码 php实现的高效日历代码&&&&&&php日历代码分享。
* php日历功能
* edit: www.
@date_default_timezone_set('RPC');
function show_calender(){
$starttime=microtime();
//处理请求日期
isset()($_GET["y"]) ? int......&&&&?php日历代码 三个不错的php日历代码&&&&&&1,php日历代码一
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
$date = isset()($_GET['date']) ? $_GET['date'] : date('Y-m......
&&&&&&最新IT科技资讯推荐:
[1]PHP阴历转农历的实现代码
&&&&来源:&互联网& 发布时间:&
**PHP阴历转农历
class Lunar {
var $MIN_YEAR = 1891;
var $MAX_YEAR = 2100;
var $lunarInfo = array(
array(0,2,9,21936),array(6,1,30,9656),array(0,2,17,9584),array(0,2,6,21168),array(5,1,26,43344),array(0,2,13,59728),
array(0,2,2,27296),array(3,1,22,44368),array(0,2,10,43856),array(8,1,30,19304),array(0,2,19,19168),array(0,2,8,42352),
array(5,1,29,21096),array(0,2,16,53856),array(0,2,4,55632),array(4,1,25,27304),array(0,2,13,22176),array(0,2,2,39632),
array(2,1,22,19176),array(0,2,10,19168),array(6,1,30,42200),array(0,2,18,42192),array(0,2,6,53840),array(5,1,26,54568),
array(0,2,14,46400),array(0,2,3,54944),array(2,1,23,38608),array(0,2,11,38320),array(7,2,1,18872),array(0,2,20,18800),
array(0,2,8,42160),array(5,1,28,45656),array(0,2,16,27216),array(0,2,5,27968),array(4,1,24,44456),array(0,2,13,11104),
array(0,2,2,38256),array(2,1,23,18808),array(0,2,10,18800),array(6,1,30,25776),array(0,2,17,54432),array(0,2,6,59984),
array(5,1,26,27976),array(0,2,14,23248),array(0,2,4,11104),array(3,1,24,37744),array(0,2,11,37600),array(7,1,31,51560),
array(0,2,19,51536),array(0,2,8,54432),array(6,1,27,55888),array(0,2,15,46416),array(0,2,5,22176),array(4,1,25,43736),
array(0,2,13,9680),array(0,2,2,37584),array(2,1,22,51544),array(0,2,10,43344),array(7,1,29,46248),array(0,2,17,27808),
array(0,2,6,46416),array(5,1,27,21928),array(0,2,14,19872),array(0,2,3,42416),array(3,1,24,21176),array(0,2,12,21168),
array(8,1,31,43344),array(0,2,18,59728),array(0,2,8,27296),array(6,1,28,44368),array(0,2,15,43856),array(0,2,5,19296),
array(4,1,25,42352),array(0,2,13,42352),array(0,2,2,21088),array(3,1,21,59696),array(0,2,9,55632),array(7,1,30,23208),
array(0,2,17,22176),array(0,2,6,38608),array(5,1,27,19176),array(0,2,15,19152),array(0,2,3,42192),array(4,1,23,53864),
array(0,2,11,53840),array(8,1,31,54568),array(0,2,18,46400),array(0,2,7,46752),array(6,1,28,38608),array(0,2,16,38320),
array(0,2,5,18864),array(4,1,25,42168),array(0,2,13,42160),array(10,2,2,45656),array(0,2,20,27216),array(0,2,9,27968),
array(6,1,29,44448),array(0,2,17,43872),array(0,2,6,38256),array(5,1,27,18808),array(0,2,15,18800),array(0,2,4,25776),
array(3,1,23,27216),array(0,2,10,59984),array(8,1,31,27432),array(0,2,19,23232),array(0,2,7,43872),array(5,1,28,37736),
array(0,2,16,37600),array(0,2,5,51552),array(4,1,24,54440),array(0,2,12,54432),array(0,2,1,55888),array(2,1,22,23208),
array(0,2,9,22176),array(7,1,29,43736),array(0,2,18,9680),array(0,2,7,37584),array(5,1,26,51544),array(0,2,14,43344),
array(0,2,3,46240),array(4,1,23,46416),array(0,2,10,44368),array(9,1,31,21928),array(0,2,19,19360),array(0,2,8,42416),
array(6,1,28,21176),array(0,2,16,21168),array(0,2,5,43312),array(4,1,25,29864),array(0,2,12,27296),array(0,2,1,44368),
array(2,1,22,19880),array(0,2,10,19296),array(6,1,29,42352),array(0,2,17,42208),array(0,2,6,53856),array(5,1,26,59696),
array(0,2,13,54576),array(0,2,3,23200),array(3,1,23,27472),array(0,2,11,38608),array(11,1,31,19176),array(0,2,19,19152),
array(0,2,8,42192),array(6,1,28,53848),array(0,2,15,53840),array(0,2,4,54560),array(5,1,24,55968),array(0,2,12,46496),
array(0,2,1,22224),array(2,1,22,19160),array(0,2,10,18864),array(7,1,30,42168),array(0,2,17,42160),array(0,2,6,43600),
array(5,1,26,46376),array(0,2,14,27936),array(0,2,2,44448),array(3,1,23,21936),array(0,2,11,37744),array(8,2,1,18808),
array(0,2,19,18800),array(0,2,8,25776),array(6,1,28,27216),array(0,2,15,59984),array(0,2,4,27424),array(4,1,24,43872),
array(0,2,12,43744),array(0,2,2,37600),array(3,1,21,51568),array(0,2,9,51552),array(7,1,29,54440),array(0,2,17,54432),
array(0,2,5,55888),array(5,1,26,23208),array(0,2,14,22176),array(0,2,3,42704),array(4,1,23,21224),array(0,2,11,21200),
array(8,1,31,43352),array(0,2,19,43344),array(0,2,7,46240),array(6,1,27,46416),array(0,2,15,44368),array(0,2,5,21920),
array(4,1,24,42448),array(0,2,12,42416),array(0,2,2,21168),array(3,1,22,43320),array(0,2,9,26928),array(7,1,29,29336),
array(0,2,17,27296),array(0,2,6,44368),array(5,1,26,19880),array(0,2,14,19296),array(0,2,3,42352),array(4,1,24,21104),
array(0,2,10,53856),array(8,1,30,59696),array(0,2,18,54560),array(0,2,7,55968),array(6,1,27,27472),array(0,2,15,22224),
array(0,2,5,19168),array(4,1,25,42216),array(0,2,12,42192),array(0,2,1,53584),array(2,1,21,55592),array(0,2,9,54560)
* 将阳历转换为阴历
* @param year 公历-年
* @param month 公历-月
* @param date 公历-日
function convertSolarToLunar($year,$month,$date){
$yearData = $this-&lunarInfo[$year-$this-&MIN_YEAR];
if($year==$this-&MIN_YEAR&&$month&=2&&$date&=9){
return array(1891,'正月','初一','辛卯',1,1,'兔');
return $this-&getLunarByBetween($year,$this-&getDaysBetweenSolar($year,$month,$date,$yearData[1],$yearData[2]));
function convertSolarMonthToLunar($year,$month) {
$yearData = $this-&lunarInfo[$year-$this-&MIN_YEAR];
if($year==$this-&MIN_YEAR&&$month&=2&&$date&=9){
return array(1891,'正月','初一','辛卯',1,1,'兔');
$month_days_ary = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$dd = $month_days_ary[$month];
if($this-&isLeapYear($year) && $month == 2) $dd++;
$lunar_ary = array();
for ($i = 1; $i & $ $i++) {
$array = $this-&getLunarByBetween($year,$this-&getDaysBetweenSolar($year, $month, $i, $yearData[1], $yearData[2]));
$array[] = $year . '-' . $month . '-' . $i;
$lunar_ary[$i] = $
return $lunar_
* 将阴历转换为阳历
* @param year 阴历-年
* @param month 阴历-月,闰月处理:例如如果当年闰五月,那么第二个五月就传六月,相当于阴历有13个月,只是有的时候第13个月的天数为0
* @param date 阴历-日
function convertLunarToSolar($year,$month,$date){
$yearData = $this-&lunarInfo[$year-$this-&MIN_YEAR];
$between = $this-&getDaysBetweenLunar($year,$month,$date);
$res = mktime(0,0,0,$yearData[1],$yearData[2],$year);
$res = date('Y-m-d', $res+$between*24*60*60);
= explode()('-', $res);
= $day[0];
$month= $day[1];
= $day[2];
return array($year, $month, $day);
* 判断是否是闰年
* @param year
function isLeapYear($year){
return (($year%4==0 && $year%100 !=0) || ($year%400==0));
* 获取干支纪年
* @param year
function getLunarYearName($year){
$sky = array('庚','辛','壬','癸','甲','乙','丙','丁','戊','己');
$earth = array('申','酉','戌','亥','子','丑','寅','卯','辰','巳','午','未');
$year = $year.'';
return $sky[$year{3}].$earth[$year%12];
* 根据阴历年获取生肖
* @param year 阴历年
function getYearZodiac($year){
$zodiac = array('猴','鸡','狗','猪','鼠','牛','虎','兔','龙','蛇','马','羊');
return $zodiac[$year%12];
* 获取阳历月份的天数
* @param year 阳历-年
* @param month 阳历-月
function getSolarMonthDays($year,$month){
$monthHash = array('1'=&31,'2'=&$this-&isLeapYear($year)?29:28,'3'=&31,'4'=&30,'5'=&31,'6'=&30,'7'=&31,'8'=&31,'9'=&30,'10'=&31,'11'=&30,'12'=&31);
return $monthHash["$month"];
* 获取阴历月份的天数
* @param year 阴历-年
* @param month 阴历-月,从一月开始
function getLunarMonthDays($year,$month){
$monthData = $this-&getLunarMonths($year);
return $monthData[$month-1];
* 获取阴历每月的天数的数组
* @param year
function getLunarMonths($year){
$yearData = $this-&lunarInfo[$year - $this-&MIN_YEAR];
$leapMonth = $yearData[0];
$bit = decbin($yearData[3]);
for ($i = 0; $i & strlen($bit);$i ++) {
$bitArray[$i] = substr($bit, $i, 1);
for($k=0,$klen=16-count($bitArray);$k&$$k++){
array_unshift($bitArray, '0');
$bitArray = array_slice($bitArray,0,($leapMonth==0?12:13));
for($i=0; $i&count($bitArray); $i++){
$bitArray[$i] = $bitArray[$i] + 29;
return $bitA
* 获取农历每年的天数
* @param year 农历年份
function getLunarYearDays($year){
$yearData = $this-&lunarInfo[$year-$this-&MIN_YEAR];
$monthArray = $this-&getLunarYearMonths($year);
$len = count($monthArray);
return ($monthArray[$len-1]==0?$monthArray[$len-2]:$monthArray[$len-1]);
function getLunarYearMonths($year){
$monthData = $this-&getLunarMonths($year);
$res=array();
$yearData = $this-&lunarInfo[$year-$this-&MIN_YEAR];
$len = ($yearData[0]==0?12:13);
for($i=0;$i&$$i++){
for($j=0;$j&=$i;$j++){
$temp+=$monthData[$j];
array_push($res, $temp);
* 获取闰月
* @param year 阴历年份
function getLeapMonth($year){
$yearData = $this-&lunarInfo[$year-$this-&MIN_YEAR];
return $yearData[0];
* 计算阴历日期与正月初一相隔的天数
* @param year
* @param month
* @param date
function getDaysBetweenLunar($year,$month,$date){
$yearMonth = $this-&getLunarMonths($year);
for($i=1;$i&$$i++){
$res +=$yearMonth[$i-1];
$res+=$date-1;
* 计算2个阳历日期之间的天数
* @param year 阳历年
* @param cmonth
* @param cdate
* @param dmonth 阴历正月对应的阳历月份
* @param ddate 阴历初一对应的阳历天数
function getDaysBetweenSolar($year,$cmonth,$cdate,$dmonth,$ddate){
$a = mktime(0,0,0,$cmonth,$cdate,$year);
$b = mktime(0,0,0,$dmonth,$ddate,$year);
return ceil(($a-$b)/24/3600);
* 根据距离正月初一的天数计算阴历日期,比如今天是农历几月几日星期几等
* @param year 阳历年
* @param between 天数
function getLunarByBetween($year,$between){
$lunarArray = array();
$yearMonth=array();
$leapMonth=0;
if($between==0){
array_push($lunarArray, $year,'正月','初一');
$year = $between&0? $year : ($year-1);
$yearMonth = $this-&getLunarYearMonths($year);
$leapMonth = $this-&getLeapMonth($year);
$between = $between&0?$between : ($this-&getLunarYearDays($year)+$between);
for($i=0;$i&13;$i++){
if($between==$yearMonth[$i]){
}else if($between&$yearMonth[$i]){
$e=$between-(empty($yearMonth[$i-1])?0:$yearMonth[$i-1])+1;
$m = ($leapMonth!=0&&$t==$leapMonth+1)?('闰'.$this-& getCapitalNum($t- 1,true)):$this-&getCapitalNum(($leapMonth!=0&&$leapMonth+1&$t?($t-1):$t),true);
array_push($lunarArray,$year,$m,$this-&getCapitalNum($e,false));
array_push($lunarArray,$this-&getLunarYearName($year));// 天干地支
array_push($lunarArray,$t,$e);
array_push($lunarArray,$this-&getYearZodiac($year));// 12生肖
array_push($lunarArray,$leapMonth);// 闰几月
return $lunarA
* 获取数字的阴历叫法
* @param num 数字
* @param isMonth 是否是月份的数字
function getCapitalNum($num,$isMonth){
$isMonth = $isMonth ||
$dateHash=array('0'=&'','1'=&'一','2'=&'二','3'=&'三','4'=&' 四','5'=&'五','6'=&'六','7'=&'七','8'=&'八','9'=&'九','10'=& '十 ');
$monthHash=array('0'=&'','1'=&'正月','2'=&'二月','3'=&'三月','4'=&'四月','5'=&'五月','6'=&'六月','7'=&'七月','8'=&'八月','9'=&'九月 ','10'=&'十月','11'=&'冬月','12'=&'腊月');
if($isMonth){
$res = $monthHash[$num];
if($num&=10){
$res = '初'.$dateHash[$num];
}else if($num&10&&$num&20){
$res = '十'.$dateHash[$num-10];
}else if($num==20){
$res = "二十";
}else if($num&20&&$num&30){
$res = "廿".$dateHash[$num-20];
}else if($num==30){
$res = "三十";
$lunar = new Lunar();
$month = $lunar-&convertLunarToSolar();
print_r($month);
[2]php日历代码 php实现的高效日历代码
&&&&来源:&互联网& 发布时间:&
* php日历功能
* edit: www.
@date_default_timezone_set('RPC');
function show_calender(){
$starttime=microtime();
//处理请求日期
isset()($_GET["y"]) ? intval($_GET["y"]) : date("Y");
isset($_GET["m"]) ? intval($_GET["m"]) : date("m");
if($m&1 || $m&12)$m=date("m");
if($y&=0)$y=date("Y");
if($nm&12){
if($pm&1){
//获取本月名称
$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 "&table&\n&thead&&tr&&th colspan='1'&&a href='?y={$py}&m={$pm}'&-&/a&&/th&&th colspan='5'& {$y} {$month} &/th&&th colspan='1'&&a href='?y={$ny}&m={$nm}'&+&/a&&/th&&/tr&&thead&\n&tbody&&tr&&td&日&/td&&td&一&/td&&td&二&/td&&td&三&/td&&td&四&/td&&td&五&/td&&td&六&/td&&/tr&";
//处理日历
echo "&tr&";
if($row==0){
for($i=0;$i&=6;$i++)
if($i&$index)
echo "&td&&&/td&";
echo "&td&".$day++."&/td&";
for($i=0;$i&=6;$i++)
if($day&$lastday)
echo "&td&&&/td&";
echo "&td&".$day++."&/td&";
echo "&/tr&";
if($day&$lastday)
echo "&/table&";
$endtime=microtime();
$usedtime=$endtime-$
$run_info=array();
for($i=0;$i&10;$i++)
$run_info[]=show_calender();
print_r($run_info);
测试结果:
[0] =& 0.00005
[1] =& 0.99998
[2] =& 0.99999
[3] =& 0.000303
[4] =& 0.99997
[5] =& 0.99998
[6] =& 0.00002
[7] =& 0.00033
[8] =& 0.99997
[9] =& 0.00004
[3]php日历代码 三个不错的php日历代码
&&&&来源:&互联网& 发布时间:&
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 = '&table border="1"&';
$html .= '&tr&';
$html .= '&td&&a href="' . $PHP_SELF . '?date=' . $pre . '"&-&/a&&/td&';
$html .= '&td colspan="5"&' . $date['year'] . ';' . $date['month'] . '&/td&';
$html .= '&td&&a href="' . $PHP_SELF . '?date=' . $next . '"&+&/a&&/td&';
$html .= '&/tr&';
$arr_tpl = array(0 =& '', 1 =& '', 2 =& '', 3 =& '', 4 =& '', 5 =& '', 6 =& '');
$date_arr = array();
for ($i = 0; $i & $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
foreach ($date_arr as $value) {
$html .= '&tr&';
foreach ($value as $v) {
if ($v == $date['mday']) {
$html .= '&td&&b&' . $v . '&/b&&/td&';
$html .= '&td&' . $v . '&/td&';
$html .= '&td& &/td&';
$html .= '&/tr&';
$html .= '&/table&';
2,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 = '&table width="200" border="1" cellspacing="0" bordercolor="#999999"
align="center" &';
$html .= '&tr&';
$html .= '&td&&a href="' . $PHP_SELF . '?date=' . $pre . '"&-&/a&&/td&';
$html .= '&td colspan="5"&' . $date['year'] . ';' . $date['month'] . '&/td&';
$html .= '&td&&a href="' . $PHP_SELF . '?date=' . $next . '"&+&/a&&/td&';
$html .= '&/tr&';
$arr_tpl = array(0 =& '', 1 =& '', 2 =& '', 3 =& '', 4 =& '', 5 =& '', 6 =& '');
$date_arr = array();
for ($i = 0; $i & $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
foreach ($date_arr as $value) {
$html .= '&tr&';
foreach ($value as $v) {
if ($v == $date['mday']) {
$html .= '&td&&b&' . $v . '&/b&&/td&';
$html .= '&td&' . $v . '&/td&';
$html .= '&td& &/td&';
$html .= '&/tr&';
$html .= '&/table&';
3,php日历代码三:
* php日历代码
* edit: www.
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 & 1980) $year = 1980;
$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).$
$nextyear = ($year + 1).$
echo &&&VKN
&table width="200" border="0" cellpadding="2" cellspacing="2"&
&td &&a href="?ym=$prevyear"&&&&/a&&/td&
&td &&a href="?ym=$prevmonth"&&&/a&&/td&
&td colspan="3" &$year - $month&/td&
&td &&a href="?ym=$nextmonth"&&&/a&&/td&
&td &&a href="?ym=$nextyear"&&&&/a&&/td&
&td width="27" &日&/td&
&td width="27" &一&/td&
&td width="27" &二&/td&
&td width="27" &三&/td&
&td width="27" &四&/td&
&td width="27" &五&/td&
&td width="27" &六&/td&
$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 &= $ $i++)
"&td &".($daysofprevmonth-$weekofbeginday+$i)."&/td&";
//当月全部
for($i = 1 ; $i &= $ $i++)
$css = ($count%7==0 || $count%7==1)?"weekday":"normalday";
if($i == $today) $css .= "today";
"&td .$css."'&".$i."&/td&";
if($count%7==0) echo "&/tr&&tr&";
//下月前几天
for ($i = 1;$i &= 6-$$i++)
"&td &".$i."&/td&";
echo &&&VKN
&td colspan="7"&&/td&
&!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&
&html xmlns="http://www.w3.org/1999/xhtml"&
&meta http-equiv="Content-Type" content="text/ charset=gb2312" /&
&title&calendar&/title&
&style type="text/css"&
.weekday {
font-size: 9
color: #FF0000;
text-align:
.normalday {
font-size: 9
color: #000000;
text-align:
.weekdaytoday {
font-size: 9
color: #FF0000;
text-align:
background-color: #FFD9D9;
font-weight:
.normaldaytoday {
font-size: 9
color: #000000;
text-align:
background-color: #DDDDDD;
font-weight:
.othermonth {
font-size: 9
font-style:
color: #999999;
text-align:
&?php calendar();?&
最新技术文章:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!
(C)2012-,站长邮箱:www_169it_(请将#改为@)}

我要回帖

更多关于 日历源代码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信