/** * @param TDate $D * @return mixed */ function DaysInMonth($D) { $nrOfDays = $D->isLeapYear() ? 29 : 28; $days = array(1 => 31, 2 => $nrOfDays, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31); //return 'month '.$D->getMonth().' have '.$days[$D->getMonth()].' DAYS'; return array('month' => $D->getMonth(), 'days' => $days[$D->getMonth()]); }
public function setYear($Year) { $this->Year = $Year; } /** * @return mixed */ public function getYear() { return $this->Year; } public function isLeapYear() { $result = ''; for ($i = 0; $i < $this->Day; $i += 4) { if ($this->Year == $i) { //echo $this->Year.' this is a leap year'; $result = 1; return $result; } else { // echo $this->Year.' this is not a leap year'; $result = 0; } } return $result; } } $b = new DateTime(); echo $b->format('Y-m-d H:i:s') . '<br/>'; $a = new TDate(12, 5, 2014); echo $a->isLeapYear();