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


PHP Time::toUnixString方法代码示例

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


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

示例1: persianDate

 /**
  * @param string $format
  * @param int|string|DateTime $date
  * @return mixed|string
  */
 public function persianDate($date, $format = 'Y-m-d H:i:s')
 {
     $time = new Time($date);
     //        $unix = $time->i18nFormat(\IntlDateFormatter::FULL, 'Asia/Tehran', 'en_US')->toUnixString();
     //        debug($unix);die;
     return Persian::date($format, (int) $time->toUnixString(), '', 'Asia/Tehran', 'en');
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:12,代码来源:SpiderHelper.php

示例2: testToUnix

 /**
  * testToUnix method
  *
  * @return void
  */
 public function testToUnix()
 {
     $time = new Time('2014-04-20 08:00:00');
     $this->assertEquals('1397980800', $time->toUnixString());
     $time = new Time('2021-12-11 07:00:01');
     $this->assertEquals('1639206001', $time->toUnixString());
 }
开发者ID:RogerSchmeier,项目名称:Webtruck,代码行数:12,代码来源:TimeTest.php

示例3: requestJob

 /**
  * Look for a new job that can be processed with the current abilities and
  * from the specified group (or any if null).
  *
  * @param array $capabilities Available QueueWorkerTasks.
  * @param string|null $group Request a job from this group, (from any group if null)
  * @return \Queue\Model\Entity\QueuedJob|null
  */
 public function requestJob(array $capabilities, $group = null)
 {
     $now = new Time();
     $nowStr = $now->toDateTimeString();
     $query = $this->find();
     $options = ['conditions' => ['completed IS' => null, 'OR' => []], 'fields' => ['age' => $query->newExpr()->add('IFNULL(TIMESTAMPDIFF(SECOND, "' . $nowStr . '", notbefore), 0)')], 'order' => ['priority' => 'ASC', 'age' => 'ASC', 'id' => 'ASC']];
     if ($group !== null) {
         $options['conditions']['job_group'] = $group;
     }
     // Generate the task specific conditions.
     foreach ($capabilities as $task) {
         list($plugin, $name) = pluginSplit($task['name']);
         $timeoutAt = $now->copy();
         $tmp = ['job_type' => $name, 'AND' => [['OR' => ['notbefore <' => $now, 'notbefore IS' => null]], ['OR' => ['fetched <' => $timeoutAt->subSeconds($task['timeout']), 'fetched IS' => null]]], 'failed <' => $task['retries'] + 1];
         if (array_key_exists('rate', $task) && $tmp['job_type'] && array_key_exists($tmp['job_type'], $this->rateHistory)) {
             $tmp['UNIX_TIMESTAMP() >='] = $this->rateHistory[$tmp['job_type']] + $task['rate'];
         }
         $options['conditions']['OR'][] = $tmp;
     }
     $job = $this->connection()->transactional(function () use($query, $options, $now) {
         $job = $query->find('all', $options)->autoFields(true)->first();
         if (!$job) {
             return null;
         }
         $key = $this->key();
         $job = $this->patchEntity($job, ['workerkey' => $key, 'fetched' => $now]);
         return $this->save($job);
     });
     if (!$job) {
         return null;
     }
     $this->rateHistory[$job['job_type']] = $now->toUnixString();
     return $job;
 }
开发者ID:dereuromark,项目名称:cakephp-queue,代码行数:42,代码来源:QueuedJobsTable.php


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