php日历
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php日历,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2405字,纯文字阅读大概需要4分钟。
内容图文
year = date ( 'Y' ); $this->month = date ( 'm' ); $this->val = $val; $vars = get_class_vars ( get_class ( $this ) ); foreach ( $options as $key => $value ) { if (array_key_exists ( $key, $vars )) { $this->$key = $value; } } } function display() { $value .= '
'; $value .= $this->showChangeDate (); $value .= $this->showWeeks (); $value .= $this->showDays ( $this->year, $this->month ); $value .= '
'; return $value; } private function showWeeks() { $value .= '
'; foreach ( $this->weeks as $title ) { $value .= '' . $title . ' | '; } $value .= '
'; return $value; } private function showDays($year, $month) { $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 <= $weekofbeginday ; $i++) { $value .= "
".($daysofprevmonth-$weekofbeginday+$i)." | "; $count++; } //当月全部 for($i = 1 ; $i <= $daysofmonth ; $i++) { $css = ($count%7==0 || $count%7==1)?"weekday":"normalday"; if($i == $today) $css .= "today"; $value .= "
".$i." | "; if($count%7==0) $value .= "
"; $count++; } //下月前几天 for ($i = 1;$i <= 6-$weekofendday;$i++) { $value .= "".$i." | "; } $value .= '
'; return $value; } private function showChangeDate() { $url = basename ( $_SERVER ['PHP_SELF'] ); $value = '
'; $value .= 'preYearUrl ( $this->year, $this->month ) . '">' . '上年' . ' | '; $value .= 'preMonthUrl ( $this->year, $this->month ) . '">' . '上月' . ' | '; $value .= ' | '; $value .= 'nextMonthUrl ( $this->year, $this->month ) . '">' . '下月' . ' | '; $value .= 'nextYearUrl ( $this->year, $this->month ) . '">' . '下年' . ' | '; $value .= '
'; return $value; } private function preYearUrl($year, $month) { $year = ($this->year <= 1970) ? 1970 : $year - 1; return 'year=' . $year . '&month=' . $month; } private function nextYearUrl($year, $month) { $year = ($year >= 2038) ? 2038 : $year + 1; return 'year=' . $year . '&month=' . $month; } private function preMonthUrl($year, $month) { if ($month == 1) { $month = 12; $year = ($year <= 1970) ? 1970 : $year - 1; } else { $month --; } return 'year=' . $year . '&month=' . $month; } private function nextMonthUrl($year, $month) { if ($month == 12) { $month = 1; $year = ($year >= 2038) ? 2038 : $year + 1; } else { $month ++; } return 'year=' . $year . '&month=' . $month; }}
$year, 'month' => $month );if (isset ( $_GET ['year'] ) && isset ( $_GET ['month'] )) { $params = array ('year' => $_GET ['year'], 'month' => $_GET ['month'] ); $year = $_GET ['year']; $month = $_GET ['month'];}$cal = new Calendar ( $params, $list_sign );echo $cal->display ();?>
内容总结
以上是互联网集市为您收集整理的php日历全部内容,希望文章能够帮你解决php日历所遇到的程序开发问题。
如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
来源:【匿名】