php专区

 首页 > php专区 > PHP应用 > php类库 > 非常简单的日历类 - php类库

非常简单的日历类 - php类库

分享到:
【字体:
导读:
          date_default_timezone_set(etc gmt-8);classcalendar{var$t=array();var$datesofmonth=array( 39;1 39;= 39;31 39;, 39;2 39;=...

非常简单的日历类

  1. date_default_timezone_set("etc/gmt-8"); 
  2. class calendar{ 
  3. var $t = array(); 
  4. var $datesofmonth = array('1'=>'31','2'=>'28','3'=>'31','4'=>'30','5'=>'31','6'=>'30','7'=>'31','8'=>'31','9'=>'30','10'=>'31','11'=>'30','12'=>'31'); 
  5. var $y,$m,$d
  6. function set($time){ 
  7. $this->t = getdate($time); 
  8. $this->y = $this->t['year']; 
  9. $this->m = $this->t['mon']; 
  10. $this->d = date('d',$time); 
  11. function isrun(){ 
  12. return ($this->y%400==0 || ($this->y%4==0 && $this->y%100==0)) ? 1 : 0; 
  13. function first(){ 
  14. $time = mktime(0,0,0,$this->m,1,$this->y); 
  15. $time = getdate($time); 
  16. return $time['wday']; 
  17. function html(){ 
  18. $isrun = $this->isrun(); 
  19. $this->datesofmonth[2] = $isrun==1 ? 29: 28; 
  20. $html .= "n"
  21. $html .= "上一月{$this->y}年 {$this->m}月下一月n"
  22. $html .= "星期天星期一星期二111cn.net星期三星期四星期五星期六n"
  23. $html .= "n"
  24. $first = $this->first(); 
  25. for($i=0; $i<$first$i++){ 
  26. $html .= ""
  27. $count = $this->datesofmonth[$this->m]+$first
  28. for ($i=1; $i<= $this->datesofmonth[$this->m]; $i++){ 
  29. $style = $i==$this->d ? ' style="color:red;font-weight:bold;"' : '' ; 
  30. $html .= "$i"
  31. if (($i==7%$first || ($i+$first)%7==0) && $i<$count){ 
  32. $html .= "n"
  33. $count = 7-$count%7; 
  34. if ($count<7){ 
  35. for ($i=0; $i<$count$i++){ 
  36. $html .= ""
  37. $html .= "n"
  38. $html .= "n"
  39. return $html
  40. $calendar = new calendar(); 
  41. $calendar->set(time()); 
  42. echo $calendar->html(); 
分享到:
PHP分页类 - php类库
PHP分页类  
php数字分页类的代码 - php类库
php数字分页类的代码 下面是一款php数字分页类的代码,己经封装好了的代码,需要的朋友可以参考使用一下,分页的主要原理就是获取当前页面,再判断一页多少条记录相除,得出总记录,就这么简单了。 function getnavhtml($pagenum,$pagesize,$rowcount,$navurl){   $pagecount = (int)($...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……