当前位置: 首页>>代码示例>>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;未经允许,请勿转载。