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


PHP Date::set方法代码示例

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


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

示例1: getLastBuildDate

 /**
  * Get the feed lastBuild date
  *
  * @return Date\Date
  */
 public function getLastBuildDate()
 {
     if (array_key_exists('lastBuildDate', $this->_data)) {
         return $this->_data['lastBuildDate'];
     }
     $lastBuildDate = null;
     $date = null;
     if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) {
         $lastBuildDate = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)');
         if ($lastBuildDate) {
             $lastBuildDateParsed = strtotime($lastBuildDate);
             if ($lastBuildDateParsed) {
                 $date = new Date\Date($lastBuildDateParsed);
             } else {
                 $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, Date\Date::RFC_2822, Date\Date::DATES);
                 $date = new Date\Date();
                 foreach ($dateStandards as $standard) {
                     try {
                         $date->set($lastBuildDate, $standard);
                         break;
                     } catch (Date\Exception $e) {
                         if ($standard == Date\Date::DATES) {
                             throw new Exception('Could not load date due to unrecognised' . ' format (should follow RFC 822 or 2822):' . $e->getMessage(), 0, $e);
                         }
                     }
                 }
             }
         }
     }
     if (!$date) {
         $date = null;
     }
     $this->_data['lastBuildDate'] = $date;
     return $this->_data['lastBuildDate'];
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:40,代码来源:Rss.php

示例2: getUpdateBase

 /**
  * Get update base
  *
  * @return Date\Date|null
  */
 public function getUpdateBase()
 {
     $updateBase = $this->_getData('updateBase');
     $date = null;
     if ($updateBase) {
         $date = new Date\Date();
         $date->set($updateBase, Date\Date::W3C);
     }
     return $date;
 }
开发者ID:stunti,项目名称:zf2,代码行数:15,代码来源:Feed.php

示例3: listDecorator

 /**
  * Decorator to format return value of list methods
  *
  * @param array $result
  * @return string
  */
 public static function listDecorator($result)
 {
     $ret = '';
     $date = new Date();
     if (count($result) > 0) {
         foreach ($result as $record) {
             $date->set($record['createTime']);
             $createTimeFormatted = $date->get(Date::RFC_1123);
             $date->set($record['modifyTime']);
             $modifyTimeFormatted = $date->get(Date::RFC_1123);
             $ret .= sprintf('         Filename  : %s%s', $record['filename'], PHP_EOL);
             $ret .= sprintf('         File Size : %d b%s', $record['fileSize'], PHP_EOL);
             $ret .= sprintf('     Creation Time : %d (%s)%s', $record['createTime'], $createTimeFormatted, PHP_EOL);
             $ret .= sprintf('Last Modified Time : %d (%s)%s', $record['modifyTime'], $modifyTimeFormatted, PHP_EOL);
             $ret .= PHP_EOL;
         }
     }
     unset($date);
     return $ret;
 }
开发者ID:rexmac,项目名称:zf2,代码行数:26,代码来源:Helper.php

示例4: getDate

 /**
  *
  *
  * @return Date\Date|null
  */
 public function getDate()
 {
     if (array_key_exists('date', $this->_data)) {
         return $this->_data['date'];
     }
     $d = null;
     $date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
     if (!$date) {
         $date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
     }
     if ($date) {
         $d = new Date\Date();
         $d->set($date, Date\Date::ISO_8601);
     }
     $this->_data['date'] = $d;
     return $this->_data['date'];
 }
开发者ID:rexmac,项目名称:zf2,代码行数:22,代码来源:Feed.php

示例5: getDateModified

 /**
  * Get the entry modification date
  *
  * @return string
  */
 public function getDateModified()
 {
     if (array_key_exists('datemodified', $this->_data)) {
         return $this->_data['datemodified'];
     }
     $date = null;
     if ($this->_getAtomType() === Reader\Reader::TYPE_ATOM_03) {
         $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)');
     } else {
         $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)');
     }
     if ($dateModified) {
         $date = new Date\Date();
         $date->set($dateModified, Date\Date::ISO_8601);
     }
     $this->_data['datemodified'] = $date;
     return $this->_data['datemodified'];
 }
开发者ID:brikou,项目名称:zend_feed,代码行数:23,代码来源:Entry.php

示例6: testZendDateSerializedToAmf0Date

 public function testZendDateSerializedToAmf0Date()
 {
     $date = new Date\Date('October 23, 1978', null, 'en_US');
     $date->set('4:20:00', Date\Date::TIMES);
     $newBody = new Value\MessageBody('/1/onResult', null, $date);
     $this->_response->setObjectEncoding(0x0);
     $this->_response->addAmfBody($newBody);
     $this->_response->finalize();
     $testResponse = $this->_response->getResponse();
     // Load the expected response.
     $mockResponse = file_get_contents(__DIR__ . '/TestAsset/Response/dateAmf0Response.bin');
     // Check that the response matches the expected serialized value
     $this->assertEquals($mockResponse, $testResponse);
 }
开发者ID:stunti,项目名称:zf2,代码行数:14,代码来源:ResponseTest.php

示例7: testGetsDateModifiedFromAtom10

 /**
  * Get modification date (Unencoded Text)
  * @group ZFR002
  */
 public function testGetsDateModifiedFromAtom10()
 {
     $entry = Reader\Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/atom10.xml'));
     $edate = new Date\Date();
     $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601);
     $this->assertTrue($edate->equals($entry->getDateModified()));
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:11,代码来源:AtomStandaloneEntryTest.php

示例8: getDateModified

 /**
  * Get the entry's date of modification
  *
  * @return string
  */
 public function getDateModified()
 {
     if (array_key_exists('datemodified', $this->_data)) {
         return $this->_data['datemodified'];
     }
     $dateModified = null;
     $date = null;
     if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) {
         $dateModified = $this->_xpath->evaluate('string(' . $this->_xpathQueryRss . '/pubDate)');
         if ($dateModified) {
             $dateModifiedParsed = strtotime($dateModified);
             if ($dateModifiedParsed) {
                 $date = new Date\Date($dateModifiedParsed);
             } else {
                 $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, Date\Date::RFC_2822, Date\Date::DATES);
                 $date = new Date\Date();
                 foreach ($dateStandards as $standard) {
                     try {
                         $date->set($dateModified, $standard);
                         break;
                     } catch (Date\Exception $e) {
                         if ($standard == Date\Date::DATES) {
                             require_once 'Zend/Feed/Exception.php';
                             throw new Exception('Could not load date due to unrecognised' . ' format (should follow RFC 822 or 2822):' . $e->getMessage(), 0, $e);
                         }
                     }
                 }
             }
         }
     }
     if (!$date) {
         $date = $this->getExtension('DublinCore')->getDate();
     }
     if (!$date) {
         $date = $this->getExtension('Atom')->getDateModified();
     }
     if (!$date) {
         $date = null;
     }
     $this->_data['datemodified'] = $date;
     return $this->_data['datemodified'];
 }
开发者ID:brikou,项目名称:zend_feed,代码行数:47,代码来源:Rss.php

示例9: testGetsDateModifiedFromRss20_UnrecognisedGmtFormat

 /**
  * @issue ZF-7908
  */
 public function testGetsDateModifiedFromRss20_UnrecognisedGmtFormat()
 {
     $feed = Reader\Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/plain/rss20-zf-7908.xml'));
     $entry = $feed->current();
     //$this->assertEquals('Sunday 11 January 2009 09 55 59 +0000', $entry->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
     $edate = new Date\Date();
     $edate->set('Sun, 11 Jan 2009 09:55:59 GMT', Date\Date::RSS);
     $this->assertTrue($edate->equals($entry->getDateModified()));
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:12,代码来源:RssTest.php

示例10: testComparingDatesWithoutOption

 /**
  * @ZF-9891
  */
 public function testComparingDatesWithoutOption()
 {
     $date = new Date(strtotime('Sat, 07 Mar 2009 08:03:50 +0000'));
     $date2 = new Date();
     $date2->set('Sat, 07 Mar 2009 08:03:50 +0000', Date::RFC_2822);
     $this->assertTrue($date2->equals($date));
 }
开发者ID:rikaix,项目名称:zf2,代码行数:10,代码来源:DateTest.php

示例11: testCreateBuckets

 /**
  * Test create bucket
  *
  * @return void
  */
 public function testCreateBuckets()
 {
     //Valid bucket name
     $bucket = 'iamavalidbucket';
     $location = '';
     $requestDate = new Date();
     $requestDate->set('Tue, 15 May 2012 15:18:31 +0000', Date::RFC_1123);
     $this->amazon->setRequestDate($requestDate);
     $this->amazon->setKeys('AKIAIDCZ2WXN6NNB7YZA', 'sagA0Lge8R+ifORcyb6Z/qVbmtimFCUczvh51Jq8');
     //Fake keys
     /**
      * Check of request inside _makeRequest
      * 
      */
     $this->uriHttp->expects($this->once())->method('getHost')->with()->will($this->returnValue('s3.amazonaws.com'));
     $this->uriHttp->expects($this->once())->method('setHost')->with('iamavalidbucket.s3.amazonaws.com');
     $this->uriHttp->expects($this->once())->method('setPath')->with('/');
     $this->httpClient->expects($this->once())->method('setUri')->with($this->uriHttp);
     $this->httpClient->expects($this->once())->method('setMethod')->with('PUT');
     $this->httpClient->expects($this->once())->method('setHeaders')->with(array("Date" => "Tue, 15 May 2012 15:18:31 +0000", "Content-Type" => "application/xml", "Authorization" => "AWS AKIAIDCZ2WXN6NNB7YZA:Y+T4nZxI1wBi1Yn1BMnOK9CDiOM="));
     /**
      * Fake response inside _makeRequest
      *
      */
     // Http Response results
     $this->httpResponse->expects($this->any())->method('getStatusCode')->will($this->returnValue(200));
     // Expects to be called only once the method send() then return a Http Response.
     $this->httpClient->expects($this->once())->method('send')->will($this->returnValue($this->httpResponse));
     $response = $this->amazon->createBucket($bucket, $location);
     $this->assertTrue($response);
 }
开发者ID:rudrud,项目名称:zf2,代码行数:36,代码来源:S3RestTest.php

示例12: 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:stunti,项目名称:zf2,代码行数:16,代码来源:DateTest.php


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