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


PHP Zend_Date_DateObject::mktime方法代碼示例

本文整理匯總了PHP中Zend_Date_DateObject::mktime方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Date_DateObject::mktime方法的具體用法?PHP Zend_Date_DateObject::mktime怎麽用?PHP Zend_Date_DateObject::mktime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Date_DateObject的用法示例。


在下文中一共展示了Zend_Date_DateObject::mktime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _calculate


//.........這裏部分代碼省略.........
                         $date = $date['gmtsecs'];
                     }
                     break;
                 default:
                     require_once 'Zend/Date/Exception.php';
                     throw new Zend_Date_Exception("datepart for part ({$part}) not found in array");
                     break;
             }
         } else {
             $hours = 0;
             if (isset($date['hour']) === true) {
                 $hours = $date['hour'];
             }
             $minutes = 0;
             if (isset($date['minute']) === true) {
                 $minutes = $date['minute'];
             }
             $seconds = 0;
             if (isset($date['second']) === true) {
                 $seconds = $date['second'];
             }
             $months = 0;
             if (isset($date['month']) === true) {
                 $months = $date['month'];
             }
             $days = 0;
             if (isset($date['day']) === true) {
                 $days = $date['day'];
             }
             $years = 0;
             if (isset($date['year']) === true) {
                 $years = $date['year'];
             }
             return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, $months, $days, $years, true), $this->mktime($hour, $minute, $second, $month, $day, $year, true), $hour);
         }
     }
     // $date as object, part of foreign date as own date
     switch ($part) {
         // day formats
         case self::DAY:
             if (is_numeric($date)) {
                 return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true), $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
             }
             require_once 'Zend/Date/Exception.php';
             throw new Zend_Date_Exception("invalid date ({$date}) operand, day expected", 0, null, $date);
             break;
         case self::WEEKDAY_SHORT:
             $daylist = Zend_Locale_Data::getList($locale, 'day');
             $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
             $cnt = 0;
             foreach ($daylist as $key => $value) {
                 if (strtoupper(iconv_substr($value, 0, 3, 'UTF-8')) == strtoupper($date)) {
                     $found = $cnt;
                     break;
                 }
                 ++$cnt;
             }
             // Weekday found
             if ($cnt < 7) {
                 return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
             }
             // Weekday not found
             require_once 'Zend/Date/Exception.php';
             throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", 0, null, $date);
             break;
         case self::DAY_SHORT:
開發者ID:arendasistemasintegrados,項目名稱:mateusleme,代碼行數:67,代碼來源:Date.php

示例2: mktime

 /**
  * Get unix timestamp.
  * Added limitation: $year value must be between -10 000 and 10 000
  * Parent method implementation causes 504 error if it gets too big(small) year value
  *
  * @see Zend_Date_DateObject::mktime
  * @throws Zend_Date_Exception
  * @param $hour
  * @param $minute
  * @param $second
  * @param $month
  * @param $day
  * @param $year
  * @param bool $gmt
  * @return float|int
  */
 protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false)
 {
     $day = intval($day);
     $month = intval($month);
     $year = intval($year);
     // correct months > 12 and months < 1
     if ($month > 12) {
         $overlap = floor($month / 12);
         $year += $overlap;
         $month -= $overlap * 12;
     } else {
         $overlap = ceil((1 - $month) / 12);
         $year -= $overlap;
         $month += $overlap * 12;
     }
     if ($year > self::YEAR_MAX_VALUE || $year < self::YEAR_MIN_VALUE) {
         throw new Zend_Date_Exception('Invalid year, it must be between ' . self::YEAR_MIN_VALUE . ' and ' . self::YEAR_MAX_VALUE);
     }
     return parent::mktime($hour, $minute, $second, $month, $day, $year, $gmt);
 }
開發者ID:newedge-media,項目名稱:medpage-easylink,代碼行數:36,代碼來源:__checkout.php

示例3: _calculate


//.........這裏部分代碼省略.........
                     if (array_key_exists('gmtsecs', $date)) {
                         $date = $date['gmtsecs'];
                     }
                     break;
                 default:
                     throw new Zend_Date_Exception("datepart for part ({$part}) not found in array");
                     break;
             }
         } else {
             $hours = 0;
             if (array_key_exists("hour", $date)) {
                 $hours = $date['hour'];
             }
             $minutes = 0;
             if (array_key_exists('minute', $date)) {
                 $minutes = $date['minute'];
             }
             $seconds = 0;
             if (array_key_exists('second', $date)) {
                 $seconds = $date['second'];
             }
             $months = 0;
             if (array_key_exists('month', $date)) {
                 $months = $date['month'];
             }
             $days = 0;
             if (array_key_exists('day', $date)) {
                 $days = $date['day'];
             }
             $years = 0;
             if (array_key_exists('year', $date)) {
                 $years = $date['year'];
             }
             return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, $months, $days, $years, true), $this->mktime($hour, $minute, $second, $month, $day, $year, true), $hour);
         }
     }
     // $date as object, part of foreign date as own date
     switch ($part) {
         // day formats
         case Zend_Date::DAY:
             if (is_numeric($date)) {
                 return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true), $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
             }
             throw new Zend_Date_Exception("invalid date ({$date}) operand, day expected", $date);
             break;
         case Zend_Date::WEEKDAY_SHORT:
             $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'format', 'wide'));
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale);
             $cnt = 0;
             foreach ($daylist as $key => $value) {
                 if (strtoupper(substr($value, 0, 3)) == strtoupper($date)) {
                     $found = $cnt;
                     break;
                 }
                 ++$cnt;
             }
             // Weekday found
             if ($cnt < 7) {
                 return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
             }
             // Weekday not found
             throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date);
             break;
         case Zend_Date::DAY_SHORT:
             if (is_numeric($date)) {
                 return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true), $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
開發者ID:renatosoares,項目名稱:blog-zend1,代碼行數:67,代碼來源:Date.php

示例4: testMkTimeforDateValuesSmallerPHPRange

 /**
  * Test for mktime
  */
 public function testMkTimeforDateValuesSmallerPHPRange()
 {
     $date = new Zend_Date_DateObject();
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1900, -1, false), -2208985200);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1900, -1, true), -2208988800);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1700, -1, false), -8520332400);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1700, -1, true), -8520336000);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1500, -1, false), -14830988400);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1500, -1, true), -14830992000);
     $this->assertSame($date->mktime(0, 0, 0, 10, 10, 1582, -1, false), -12219321600);
     $this->assertSame($date->mktime(0, 0, 0, 10, 10, 1582, -1, true), -12219321600);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1000, -1, false), -30609788400);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 1000, -1, true), -30609792000);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 0, -1, false), -62167388400);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, 0, -1, true), -62167392000);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, -2000, -1, false), -125282588400);
     $this->assertSame($date->mktime(0, 0, 0, 1, 1, -2000, -1, true), -125282592000);
     $this->assertSame($date->mktime(0, 0, 0, 13, 1, 1899, -1, false), -2208985200);
     $this->assertSame($date->mktime(0, 0, 0, 13, 1, 1899, -1, true), -2208988800);
     $this->assertSame($date->mktime(0, 0, 0, -11, 1, 1901, -1, false), -2208985200);
     $this->assertSame($date->mktime(0, 0, 0, -11, 1, 1901, -1, true), -2208988800);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:25,代碼來源:DateObjectTest.php


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