Tools\Utility\Time::daysInMonth PHP Method

daysInMonth() public static method

Return the days of a given month.
public static daysInMonth ( integer $year, integer $month ) : string
$year integer
$month integer
return string Days
    public static function daysInMonth($year, $month)
    {
        return date('t', mktime(0, 0, 0, $month, 1, $year));
    }

Usage Example

コード例 #1
0
ファイル: TimeTest.php プロジェクト: alescx/cakephp-tools
 /**
  * TimeTest::testDaysInMonth()
  *
  * @return void
  */
 public function testDaysInMonth()
 {
     //$this->out($this->_header(__FUNCTION__), true);
     $ret = $this->Time->daysInMonth('2004', '3');
     $this->assertEquals(31, $ret);
     $ret = $this->Time->daysInMonth('2006', '4');
     $this->assertEquals(30, $ret);
     $ret = $this->Time->daysInMonth('2007', '2');
     $this->assertEquals(28, $ret);
     $ret = $this->Time->daysInMonth('2008', '2');
     $this->assertEquals(29, $ret);
 }