本文整理汇总了PHP中Scalr_Util_DateTime::getIncrescentTimeInterval方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Util_DateTime::getIncrescentTimeInterval方法的具体用法?PHP Scalr_Util_DateTime::getIncrescentTimeInterval怎么用?PHP Scalr_Util_DateTime::getIncrescentTimeInterval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Util_DateTime
的用法示例。
在下文中一共展示了Scalr_Util_DateTime::getIncrescentTimeInterval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIncrescentTimeInterval
/**
* @test
* @dataProvider providerIncrescentTimeInterval
*/
public function testIncrescentTimeInterval($date, $curDate, $expected)
{
$this->assertEquals($expected, \Scalr_Util_DateTime::getIncrescentTimeInterval($date, $curDate));
$date = DateTime::createFromFormat('Y-m-d H:i:s', $date);
$curDate = DateTime::createFromFormat('Y-m-d H:i:s', $curDate);
$this->assertEquals($expected, \Scalr_Util_DateTime::getIncrescentTimeInterval($date, $curDate));
}
示例2: getContent
public function getContent($params = [])
{
if ($this->user->getType() != User::TYPE_SCALR_ADMIN) {
throw new Scalr_Exception_InsufficientPermissions();
}
$hosts = [];
foreach (ScalrHost::find() as $host) {
$hosts[] = ['host' => $host->host, 'version' => $host->version, 'edition' => $host->edition, 'revision' => empty($host->gitCommit) ? '' : $host->gitCommit, 'revDate' => empty($host->gitCommitAdded) ? '' : $host->gitCommitAdded->format('Y-m-d H:i:s O')];
}
$stateNames = ScalrService::listStateNames();
$allServices = [];
foreach (ScalrService::find([['name' => ['$nin' => ScalrService::EXCLUDED_SERVICES]]]) as $scalrService) {
$lastTime = empty($scalrService->lastFinish) ? time() : $scalrService->lastFinish->getTimestamp();
$allServices[] = ['name' => ucfirst(str_replace("_", " ", $scalrService->name)), 'numWorkers' => $scalrService->numWorkers, 'numTasks' => $scalrService->numTasks, 'lastStart' => !empty($scalrService->lastStart) ? Scalr_Util_DateTime::getIncrescentTimeInterval($scalrService->lastStart) : '', 'timeSpent' => !empty($scalrService->lastStart) ? $lastTime - $scalrService->lastStart->getTimestamp() : '', 'state' => $stateNames[$scalrService->state]];
}
return ['hosts' => $hosts, 'services' => $allServices];
}