0

0

php 日历类 日历控件

php中文网

php中文网

发布时间:2016-07-25 08:46:07

|

1585人浏览过

|

来源于php中文网

原创

";
  • }
  • public function getEndTR() {
  • $this->retunrhtml .= "
  • ";
  • }
  • protected function getDay() {
  • return $this->day;
  • }
  • protected function getMonth() {
  • return $this->month;
  • }
  • protected function getYear() {
  • return $this->year;
  • }
  • protected function isWeekend() {
  • return $this->weekend;
  • }
  • protected function isCurrent() {
  • return $this->currentdate;
  • }
  • public function getTDHref() {
  • return $this->getDay();
  • }
  • public function getTD() {
  • $class = '';
  • $td = "td";
  • if ($this->isCurrent()) {
  • $class = 'today';
  • }
  • $this->retunrhtml .= "" . $this->getTDHref() . "$td>";
  • }
  • public function getTDWeekend() {
  • $class = '';
  • $td = "td";
  • if ($this->isCurrent()) {
  • $class = 'today';
  • }
  • $this->retunrhtml .= "" . $this->getTDHref() . "$td>";
  • }
  • protected function makeCodeMonth($year, $month) {
  • $this->makeWeeks($year, $month);
  • $this->getCalendarHeader();
  • for ($i = 0; $i week); $i++) {
  • $this->getBeginTR();
  • for ($j = 0; $j
  • if (!empty($this->week[$i][$j])) {
  • $this->day = $this->week[$i][$j];
  • $this->currentdate = 0;
  • if ($this->year == date('Y') && $this->month == date('m') && $this->day == date('j')) {
  • $this->currentdate = 1;
  • }
  • if ($j == 5 || $j == 6) {
  • $this->weekend = 1;
  • $this->getTDWeekend();
  • }
  • else {
  • $this->weekend = 0;
  • $this->getTD();
  • }
  • }
  • else {
  • $this->retunrhtml .= "
  • ";
  • }
  • }
  • $this->getEndTR();
  • }
  • $this->getCalendarFooter();
  • }
  • public function getCodeMonth() {
  • $this->makeCodeMonth($this->year, $this->month);
  • return $this->retunrhtml;
  • }
  • public function showCodeMonth() {
  • echo $this->getCodeMonth();
  • }
  • }
  • class TechCalendarForm extends CalendarForm {
  • public function getTDHref() {
  • if ($this->isWeekend()) {
  • $font = "";
  • }
  • else {
  • $font = "";
  • }
  • return "" . $font . parent::getDay() . "
  • ";
  • }
  • }
  • 复制代码
    1. class CalendarForm {
    2. protected $year;
    3. protected $month;
    4. protected $day;
    5. protected $weekend;
    6. protected $currentdate;
    7. protected $dayofmonth;
    8. protected $day_count;
    9. protected $num;
    10. protected $week = array();
    11. protected $retunrhtml = "";
    12. function __construct($year, $month) {
    13. $this->makeWeeks($year, $month);
    14. }
    15. public function setYearMonth($year, $month) {
    16. $this->year = $year;
    17. $this->month = $month;
    18. }
    19. private function resetDayCount() {
    20. $this->day_count = 1;
    21. }
    22. private function setFirstWeek() {
    23. $this->num = 0;
    24. }
    25. public function getDayOfMonth($year, $month) {
    26. $this->resetDayCount();
    27. return date('t', mktime(0, 0, 0, $month, $this->day_count, $year));
    28. }
    29. private function setDayOfMonth($year, $month) {
    30. $this->dayofmonth = $this->getDayOfMonth($year, $month);
    31. }
    32. private function getDayOfWeek() {
    33. return date('w', mktime(0, 0, 0, $this->month, $this->day_count, $this->year));
    34. }
    35. public function getNextMonth() {
    36. return date('m', mktime(0, 0, 0, $this->month, 28, $this->year) + 432000);
    37. }
    38. public function getNextYear() {
    39. return date('Y', mktime(0, 0, 0, $this->month, 28, $this->year) + 432000);
    40. }
    41. public function getPrevMonth() {
    42. return date('m', mktime(0, 0, 0, $this->month, 1, $this->year) - 432000);
    43. }
    44. public function getPrevYear() {
    45. return date('Y', mktime(0, 0, 0, $this->month, 1, $this->year) - 432000);
    46. }
    47. private function makeWeeks($year, $month) {
    48. $this->setYearMonth($year, $month);
    49. $this->setDayOfMonth($this->year, $this->month);
    50. $this->setFirstWeek();
    51. $this->num = 0;
    52. for ($i = 0; $i $dayofweek = $this->getDayOfWeek();
    53. $dayofweek = $dayofweek - 1;
    54. if ($dayofweek == -1) {
    55. $dayofweek = 6;
    56. }
    57. if ($dayofweek == $i) {
    58. $this->week[$this->num][$i] = $this->day_count;
    59. $this->day_count++;
    60. }
    61. else {
    62. $this->week[$this->num][$i] = "";
    63. }
    64. }
    65. while (TRUE) {
    66. $this->num++;
    67. for ($i = 0; $i $this->week[$this->num][$i] = $this->day_count;
    68. $this->day_count++;
    69. if ($this->day_count > $this->dayofmonth) {
    70. break;
    71. }
    72. }
    73. if ($this->day_count > $this->dayofmonth) {
    74. break;
    75. }
    76. }
    77. }
    78. public function getCalendarHeader() {
    79. $this->retunrhtml =
    80. "" .
    81. "
    82. " .
    83. "
    84. " .
    85. "
    86. " .
    87. "
    88. " .
    89. "
    90. " .
    91. "
    92. " .
    93. "
    94. " .
    95. "
    96. " .
    97. "
    98. " .
    99. "
    100. " .
    101. "
    102. ";
    103. }
    104. public function getCalendarFooter() {
    105. $this->retunrhtml .= "
    106. " . $this->month . "/" . $this->year . "
      Monday Tuesday Wednesday Thursday Friday Saturday Sunday
      ";
    107. }
    108. public function getBeginTR() {
    109. $this->retunrhtml .= "
    php


    相关文章

    PHP速学教程(入门到精通)
    PHP速学教程(入门到精通)

    PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

    下载

    本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

    热门AI工具

    更多
    DeepSeek
    DeepSeek

    幻方量化公司旗下的开源大模型平台

    豆包大模型
    豆包大模型

    字节跳动自主研发的一系列大型语言模型

    通义千问
    通义千问

    阿里巴巴推出的全能AI助手

    腾讯元宝
    腾讯元宝

    腾讯混元平台推出的AI助手

    文心一言
    文心一言

    文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

    讯飞写作
    讯飞写作

    基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

    即梦AI
    即梦AI

    一站式AI创作平台,免费AI图片和视频生成。

    ChatGPT
    ChatGPT

    最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

    相关专题

    更多
    俄罗斯Yandex引擎入口
    俄罗斯Yandex引擎入口

    2026年俄罗斯Yandex搜索引擎最新入口汇总,涵盖免登录、多语言支持、无广告视频播放及本地化服务等核心功能。阅读专题下面的文章了解更多详细内容。

    178

    2026.01.28

    包子漫画在线官方入口大全
    包子漫画在线官方入口大全

    本合集汇总了包子漫画2026最新官方在线观看入口,涵盖备用域名、正版无广告链接及多端适配地址,助你畅享12700+高清漫画资源。阅读专题下面的文章了解更多详细内容。

    35

    2026.01.28

    ao3中文版官网地址大全
    ao3中文版官网地址大全

    AO3最新中文版官网入口合集,汇总2026年主站及国内优化镜像链接,支持简体中文界面、无广告阅读与多设备同步。阅读专题下面的文章了解更多详细内容。

    79

    2026.01.28

    php怎么写接口教程
    php怎么写接口教程

    本合集涵盖PHP接口开发基础、RESTful API设计、数据交互与安全处理等实用教程,助你快速掌握PHP接口编写技巧。阅读专题下面的文章了解更多详细内容。

    2

    2026.01.28

    php中文乱码如何解决
    php中文乱码如何解决

    本文整理了php中文乱码如何解决及解决方法,阅读节专题下面的文章了解更多详细内容。

    4

    2026.01.28

    Java 消息队列与异步架构实战
    Java 消息队列与异步架构实战

    本专题系统讲解 Java 在消息队列与异步系统架构中的核心应用,涵盖消息队列基本原理、Kafka 与 RabbitMQ 的使用场景对比、生产者与消费者模型、消息可靠性与顺序性保障、重复消费与幂等处理,以及在高并发系统中的异步解耦设计。通过实战案例,帮助学习者掌握 使用 Java 构建高吞吐、高可靠异步消息系统的完整思路。

    8

    2026.01.28

    Python 自然语言处理(NLP)基础与实战
    Python 自然语言处理(NLP)基础与实战

    本专题系统讲解 Python 在自然语言处理(NLP)领域的基础方法与实战应用,涵盖文本预处理(分词、去停用词)、词性标注、命名实体识别、关键词提取、情感分析,以及常用 NLP 库(NLTK、spaCy)的核心用法。通过真实文本案例,帮助学习者掌握 使用 Python 进行文本分析与语言数据处理的完整流程,适用于内容分析、舆情监测与智能文本应用场景。

    24

    2026.01.27

    拼多多赚钱的5种方法 拼多多赚钱的5种方法
    拼多多赚钱的5种方法 拼多多赚钱的5种方法

    在拼多多上赚钱主要可以通过无货源模式一件代发、精细化运营特色店铺、参与官方高流量活动、利用拼团机制社交裂变,以及成为多多进宝推广员这5种方法实现。核心策略在于通过低成本、高效率的供应链管理与营销,利用平台社交电商红利实现盈利。

    122

    2026.01.26

    edge浏览器怎样设置主页 edge浏览器自定义设置教程
    edge浏览器怎样设置主页 edge浏览器自定义设置教程

    在Edge浏览器中设置主页,请依次点击右上角“...”图标 > 设置 > 开始、主页和新建标签页。在“Microsoft Edge 启动时”选择“打开以下页面”,点击“添加新页面”并输入网址。若要使用主页按钮,需在“外观”设置中开启“显示主页按钮”并设定网址。

    72

    2026.01.26

    热门下载

    更多
    网站特效
    /
    网站源码
    /
    网站素材
    /
    前端模板

    精品课程

    更多
    相关推荐
    /
    热门推荐
    /
    最新课程
    关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送

    Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号