当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::toString方法代码示例

本文整理汇总了PHP中Zend\Date\Date::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::toString方法的具体用法?PHP Date::toString怎么用?PHP Date::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Date\Date的用法示例。


在下文中一共展示了Date::toString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _month

 /**
  * Returns the calculated month
  *
  * @param  string                          $calc    Calculation to make
  * @param  string|integer|array|\Zend\Date\Date  $month   Month to calculate with, if null the actual month is taken
  * @param  string|\Zend\Locale\Locale              $locale  Locale for parsing input
  * @return integer|\Zend\Date\Date  new time
  * @throws \Zend\Date\Exception
  */
 private function _month($calc, $month, $locale)
 {
     if ($month === null) {
         throw new Exception\InvalidArgumentException('parameter $month must be set, null is not allowed');
     }
     if ($locale === null) {
         $locale = $this->getLocale();
     }
     if ($month instanceof Date) {
         // extract month from object
         $found = $month->toString(self::MONTH_SHORT, 'iso', $locale);
     } else {
         if (is_numeric($month)) {
             $found = $month;
         } else {
             if (is_array($month)) {
                 if (isset($month['month']) === true) {
                     $month = $month['month'];
                 } else {
                     throw new Exception\InvalidArgumentException("no month given in array");
                 }
             } else {
                 $monthlist = Cldr::getList($locale, 'month');
                 $monthlist2 = Cldr::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
                 $monthlist = array_merge($monthlist, $monthlist2);
                 $found = 0;
                 $cnt = 0;
                 foreach ($monthlist as $key => $value) {
                     if (strtoupper($value) == strtoupper($month)) {
                         $found = $key % 12 + 1;
                         break;
                     }
                     ++$cnt;
                 }
                 if ($found == 0) {
                     foreach ($monthlist2 as $key => $value) {
                         if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($month)) {
                             $found = $key + 1;
                             break;
                         }
                         ++$cnt;
                     }
                 }
                 if ($found == 0) {
                     throw new Exception\InvalidArgumentException("unknown month name ({$month})");
                 }
             }
         }
     }
     $return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
     if ($calc != 'cmp') {
         return $this;
     }
     return $return;
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:64,代码来源:Date.php

示例2: writeDate

 /**
  * Convert the DateTime into an AMF Date
  *
  * @param  DateTime|\Zend\Date\Date $data
  * @return Zend\AMF\Parser\AMF0\Serializer
  */
 public function writeDate($data)
 {
     if ($data instanceof \DateTime) {
         $dateString = $data->format('U');
     } elseif ($data instanceof Date\Date) {
         $dateString = $data->toString('U');
     } else {
         throw new AMF\Exception('Invalid date specified; must be a DateTime or Zend_Date object');
     }
     $dateString *= 1000;
     // Make the conversion and remove milliseconds.
     $this->_stream->writeDouble($dateString);
     // Flash does not respect timezone but requires it.
     $this->_stream->writeInt(0);
     return $this;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:22,代码来源:Serializer.php

示例3: filter

    /**
     * Defined by Zend_Filter_Interface
     *
     * Normalizes the given input
     *
     * @param  string $value Value to normalized
     * @return string|array The normalized value
     */
    public function filter($value)
    {
        if (is_array($value)) {
            $date = new Date($value, $this->_options['locale']);
            return $date->toString($this->_options['date_format']);
        } else if ($this->_options['precision'] === 0) {
            return Format::toInteger($value, $this->_options);
        } else if ($this->_options['precision'] === null) {
            return Format::toFloat($value, $this->_options);
        }

        return Format::toNumber($value, $this->_options);
    }
开发者ID:nresni,项目名称:AriadneSandbox,代码行数:21,代码来源:NormalizedToLocalized.php

示例4: getPosts

 /**
  * Get posts matching the arguments
  *
  * If no date or url is given, most recent date will be used
  *
  * @param  string    $tag Optional filtering by tag
  * @param  Zend_Date $dt  Optional filtering by date
  * @param  string    $url Optional filtering by url
  * @throws Zend_Service_Delicious_Exception
  * @return Zend_Service_Delicious_PostList
  */
 public function getPosts($tag = null, Date $dt = null, $url = null)
 {
     $parms = array();
     if ($tag) {
         $parms['tag'] = $tag;
     }
     if ($url) {
         $parms['url'] = $url;
     }
     if ($dt) {
         $parms['dt'] = $dt->toString('Y-m-d\\TH:i:s\\Z', 'php');
     }
     $response = $this->makeRequest(self::PATH_POSTS_GET, $parms);
     return $this->_parseXmlPostList($response);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:26,代码来源:Delicious.php

示例5: testFractionalPrecision

 /**
  * @ZF-8650
  */
 public function testFractionalPrecision()
 {
     $date = new Date();
     $date->set('012345', Date::MILLISECOND);
     $this->assertEquals(3, $date->getFractionalPrecision());
     $this->assertEquals('345', $date->toString('S'));
     $date->setFractionalPrecision(6);
     $this->assertEquals(6, $date->getFractionalPrecision());
     $this->assertEquals('345000', $date->toString('S'));
     $date->add(200, Date::MILLISECOND);
     $this->assertEquals(6, $date->getFractionalPrecision());
     $this->assertEquals('345200', $date->toString('S'));
 }
开发者ID:rikaix,项目名称:zf2,代码行数:16,代码来源:DateTest.php


注:本文中的Zend\Date\Date::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。