无为清净楼资源网 Design By www.qnjia.com
本文实例讲述了PHP实现的日历功能。分享给大家供大家参考,具体如下:
<"Content-Type:text/html;charset=utf-8"); date_default_timezone_set("PRC"); $a=@$_GET["a"]; $b=@$_GET["b"]; if($a){ $a=$a; }else{ $a=date('y'); } if($b){ $b=$b; }else{ $b=date('m'); } $noe=mktime(0,0,0,$b,1,$a); //获取当前的月的一号 $year=date("Y",$noe); //当前的年 $month=date("m",$noe); //当前的月 $week=date("w",$noe); // 每个月的一号是星期几 $days=date("t",$noe); //每个月的总天数 $day=date("d"); //获取今天是几号 $as=$year-1; //获取上一年的年 $bs=$month-1; //获取上个月 $bs=$month+1; // 获取下个月 $as=$year+1; //获取下一年 "en"> <head> <meta charset="UTF-8"> <title>日历</title> <style> table{ border: 1px solid #050; } table th{ background:#000; color:#fff; border: 2px solid #050; } </style> </head> <body> <table cellpadding="0" cellspacing="0"> <tr> <th><a href="" rel="external nofollow" rel="external nofollow" ><<上一年</a></th> <th><a href="" rel="external nofollow" rel="external nofollow" ><<上个月</a></th> <th><"-".$month."-".$day "" rel="external nofollow" rel="external nofollow" >下个月</a></th> <th><a href="" rel="external nofollow" rel="external nofollow" >下一年</a></th> </tr> <tr> <th>星期日</th> <th>星期一</th> <th>星期二</th> <th>星期三</th> <th>星期四</th> <th>星期五</th> <th>星期六</th> </tr> <tr> <"<td> </td>"; //获取当月一号前面的空格 } for($k=1;$k<=$days;$k++){ if($k==$day){ echo "<th>".$k."</th>"; //输出今天是几号 }else{ echo "<td>".$k."</td>"; //输出当月天数 } if(($k+$week)%7==0){ echo "<tr></tr>"; // 一周七天换行 } } "//img.jbzj.com/file_images/article/201809/201891150957850.png" alt="" />PS:这里再为大家推荐几款时间及日期相关工具供大家参考:
在线日期/天数计算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi在线日期计算器/相差天数计算器:
http://tools.jb51.net/jisuanqi/datecalc在线日期天数差计算器:
http://tools.jb51.net/jisuanqi/onlinedatejsqUnix时间戳(timestamp)转换工具:
http://tools.jb51.net/code/unixtime更多关于PHP相关内容感兴趣的读者可查看本站专题:《php日期与时间用法总结》、《PHP数组(Array)操作技巧大全》、《PHP基本语法入门教程》、《PHP运算与运算符用法总结》、《php面向对象程序设计入门教程》、《PHP网络编程技巧总结》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
标签:
PHP,日历
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】