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


PHP Date\Date类代码示例

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


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

示例1: testSetWhenUsesZendDateObject

 public function testSetWhenUsesZendDateObject()
 {
     $entry = new Writer\Deleted();
     $entry->setWhen(new Date\Date('1234567890', Date\Date::TIMESTAMP));
     $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP);
     $this->assertTrue($myDate->equals($entry->getWhen()));
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:7,代码来源:DeletedTest.php

示例2: setSubscription

 /**
  * Save subscription to RDMBS
  *
  * @param array $data
  * @return bool
  */
 public function setSubscription(array $data)
 {
     if (!isset($data['id'])) {
         throw new PubSubHubbub\Exception('ID must be set before attempting a save');
     }
     $result = $this->_db->select(array('id' => $data['id']));
     if ($result && 0 < count($result)) {
         $data['created_time'] = $result->current()->created_time;
         $now = new Date\Date();
         if (array_key_exists('lease_seconds', $data) && $data['lease_seconds']) {
             $data['expiration_time'] = $now->add($data['lease_seconds'], Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss');
         }
         $this->_db->update($data, array('id' => $data['id']));
         return false;
     }
     $this->_db->insert($data);
     return true;
 }
开发者ID:brikou,项目名称:zend_feed,代码行数:24,代码来源:Subscription.php

示例3: setSubscription

 /**
  * Save subscription to RDMBS
  *
  * @param array $data
  * @return bool
  */
 public function setSubscription(array $data)
 {
     if (!isset($data['id'])) {
         throw new PubSubHubbub\Exception('ID must be set before attempting a save');
     }
     $result = $this->_db->find($data['id']);
     if ($result) {
         $data['created_time'] = $result->current()->created_time;
         $now = new Date\Date();
         if ($data['lease_seconds']) {
             $data['expiration_time'] = $now->add($data['lease_seconds'], Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss');
         }
         $this->_db->update($data, $this->_db->getAdapter()->quoteInto('id = ?', $data['id']));
         return false;
     }
     $this->_db->insert($data);
     return true;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:24,代码来源:Subscription.php

示例4: teardown

 public function teardown()
 {
     Date\Date::setOptions($this->_options);
 }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:4,代码来源:PodcastRss2Test.php

示例5: 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

示例6: 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

示例7: dirname

<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
/*
 * ALTERNATIVE: Specify username and password in constructor
 */
/*
$mailMerge = new MailMerge(
    array (
        'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME,
        'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD
    )
);
*/
$mailMerge->setLocalTemplate('template.doc');
$mailMerge->assign('customer_number', sprintf("#%'10s", rand(0, 1000000000)))->assign('invoice_number', sprintf("#%'10s", rand(0, 1000000000)))->assign('account_number', sprintf("#%'10s", rand(0, 1000000000)));
$billData = array('phone' => '+22 (0)333 444 555', 'date' => Date::now()->toString(Date::DATE_LONG), 'name' => 'James Henry Brown', 'service_phone' => '+22 (0)333 444 559', 'service_fax' => '+22 (0)333 444 558', 'month' => sprintf('%s %s', Date::now()->toString(Date::MONTH_NAME), Date::now()->toString(Date::YEAR)), 'monthly_fee' => '15.00', 'total_net' => '19.60', 'tax' => '19.00', 'tax_value' => '3.72', 'total' => '23.32');
$mailMerge->assign($billData);
$billConnections = array(array('connection_number' => '+11 (0)222 333 441', 'connection_duration' => '00:01:01', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 442', 'connection_duration' => '00:01:02', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 443', 'connection_duration' => '00:01:03', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 444', 'connection_duration' => '00:01:04', 'fee' => '1.15'));
$mailMerge->assign('connection', $billConnections);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
unset($mailMerge);
file_put_contents('document.pdf', $document);
开发者ID:alab1001101,项目名称:zf2,代码行数:29,代码来源:generate-document.php

示例8: testSetLastBuildDateUsesZendDateObject

 public function testSetLastBuildDateUsesZendDateObject()
 {
     $writer = new Writer\Feed();
     $writer->setLastBuildDate(new Date\Date('1234567890', Date\Date::TIMESTAMP));
     $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP);
     $this->assertTrue($myDate->equals($writer->getLastBuildDate()));
 }
开发者ID:narixx,项目名称:zf2,代码行数:7,代码来源:FeedTest.php

示例9: _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

示例10: testArrayVerification

 /**
  * ZF-6457
  */
 public function testArrayVerification()
 {
     $date = new Date\Date();
     $array = $date->toArray();
     $this->assertTrue($this->_validator->isValid($array), "array expected to be valid");
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:9,代码来源:DateTest.php

示例11: 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

示例12: recursiveRemoveDirectory

$tempDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
    recursiveRemoveDirectory($tempDirectory);
}
$logger->log(sprintf('Making temporary directory %s.', $tempDirectory), Logger::INFO);
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
for ($iteration = 1; $iteration <= $iterations; $iteration++) {
    $tempFilename = sprintf('%s%s%010s.pdf', $tempDirectory, DIRECTORY_SEPARATOR, $iteration);
    $tempFilenames[] = $tempFilename;
    $mailMerge->assign('software', randomString())->assign('licensee', randomString())->assign('company', randomString())->assign('date', Date::now()->toString(Date::DATE_LONG))->assign('time', Date::now()->toString(Date::TIME_LONG))->assign('city', randomString())->assign('country', randomString());
    $mailMerge->createDocument();
    file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
    $logger->log(sprintf('Generating temporary document %s.', $tempFilename), Logger::INFO);
}
unset($mailMerge);
// -----------------------------------------------------------------------------
// Concatenate temporary documents and write output document
$outputFilename = __DIR__ . DIRECTORY_SEPARATOR . 'document-concat.pdf';
$logger->log('Concatenating temporary documents...', Logger::INFO);
if (true === concatenatePdfFilenames($tempFilenames, $outputFilename, $processor)) {
    $logger->log(sprintf('...DONE. Saved output document as %s.', basename($outputFilename)), Logger::INFO);
} else {
    $logger->log(sprintf('...ERROR.'), Logger::ERR);
}
// -----------------------------------------------------------------------------
开发者ID:alab1001101,项目名称:zf2,代码行数:31,代码来源:generate-document-concat.php

示例13: dirname

<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')->setFieldValue('licensee', 'Henry Döner-Meyer')->setFieldValue('company', 'Megasoft Co-operation')->setFieldValue('date', Date::now()->toString(Date::DATE_LONG))->setFieldValue('time', Date::now()->toString(Date::TIME_LONG))->setFieldValue('city', 'Bremen')->setFieldValue('country', 'Germany');
$mailMerge->createDocument();
// Get all metafiles
$metaFiles = $mailMerge->getAllMetafiles();
// Get just metafiles in specified range
//$metaFiles = $mailMerge->getMetafiles(1, 2);    // fromPage, toPage
foreach ($metaFiles as $pageNumber => $metaFileData) {
    $filename = sprintf('document-page-%d.wmf', $pageNumber);
    file_put_contents($filename, $metaFileData);
}
unset($mailMerge);
开发者ID:stunti,项目名称:zf2,代码行数:19,代码来源:generate-metafiles.php

示例14: 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

示例15: 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


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