本文整理汇总了PHP中Zend\Date\Date::getFullYear方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::getFullYear方法的具体用法?PHP Date::getFullYear怎么用?PHP Date::getFullYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Date\Date
的用法示例。
在下文中一共展示了Date::getFullYear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _checkFormat
/**
* Check if the given date fits the given format
*
* @param string $value Date to check
* @return boolean False when date does not fit the format
*/
private function _checkFormat($value)
{
try {
$parsed = \Zend\Locale\Format::getDate($value, array('date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false));
if (isset($parsed['year']) and (strpos(strtoupper($this->_format), 'YY') !== false and strpos(strtoupper($this->_format), 'YYYY') === false)) {
$parsed['year'] = ZendDate\Date::getFullYear($parsed['year']);
}
} catch (\Exception $e) {
// Date can not be parsed
return false;
}
if ((strpos($this->_format, 'Y') !== false or strpos($this->_format, 'y') !== false) and !isset($parsed['year'])) {
// Year expected but not found
return false;
}
if (strpos($this->_format, 'M') !== false and !isset($parsed['month'])) {
// Month expected but not found
return false;
}
if (strpos($this->_format, 'd') !== false and !isset($parsed['day'])) {
// Day expected but not found
return false;
}
if ((strpos($this->_format, 'H') !== false or strpos($this->_format, 'h') !== false) and !isset($parsed['hour'])) {
// Hour expected but not found
return false;
}
if (strpos($this->_format, 'm') !== false and !isset($parsed['minute'])) {
// Minute expected but not found
return false;
}
if (strpos($this->_format, 's') !== false and !isset($parsed['second'])) {
// Second expected but not found
return false;
}
// Date fits the format
return true;
}
示例2: testGetFullYear
public function testGetFullYear()
{
$this->assertSame(1970, Date::getFullYear(70));
$this->assertSame(1999, Date::getFullYear(99));
$this->assertSame(2000, Date::getFullYear(0));
$this->assertSame(2037, Date::getFullYear(37));
$this->assertSame(2069, Date::getFullYear(69));
$this->assertSame(-4, Date::getFullYear(-4));
$this->assertSame(100, Date::getFullYear(100));
}