當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Date::getFullYear方法代碼示例

本文整理匯總了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;
 }
開發者ID:nsenkevich,項目名稱:zf2,代碼行數:44,代碼來源:Date.php

示例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));
 }
開發者ID:rikaix,項目名稱:zf2,代碼行數:10,代碼來源:DateTest.php


注:本文中的Zend\Date\Date::getFullYear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。