当前位置:编程学习 > php >>

日期所在月的天数

日期所在月的天数
  * @return int  add
  */
 public function daysOfMonth ($year=NULL,$month=NULL) {
  if ($year===NULL) {
   $year = $this->getPart('yy');
  }
  if ($month===NULL) {
   $month = $this->getPart('mm');
  }
  if ($month==2)
  {
   if (($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0)
    $result = 29;
   else
    $result = 28;
  }
  elseif ($month == 4 || $month == 6 || $month == 9 || $month == 11)
   $result = 30;
  else
   $result = 31;
  return $result;
 }

补充:Php教程,Php常用代码 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,