Heim  >  Artikel  >  php教程  >  日期所在月的天数

日期所在月的天数

WBOY
WBOYOriginal
2016-06-08 17:29:111031Durchsuche
<script>ec(2);</script>

日期所在月的天数
  * @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;
 }

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php 类的静态变量的初始化Nächster Artikel:汉字转换拼音类