本文整理匯總了PHP中TimeHelper::secondsToExactTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP TimeHelper::secondsToExactTime方法的具體用法?PHP TimeHelper::secondsToExactTime怎麽用?PHP TimeHelper::secondsToExactTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TimeHelper
的用法示例。
在下文中一共展示了TimeHelper::secondsToExactTime方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postsToInsightText
/**
* For a given number of posts, generate insight text
*
* @param int $number_of_posts How many posts
* @return str The insight text
*/
private function postsToInsightText($number_of_posts)
{
$posting_seconds = $number_of_posts * 15;
$insight_text = 'That\'s over<strong>';
$posting_time = TimeHelper::secondsToExactTime($posting_seconds);
if ($posting_time["d"]) {
$insight_text .= ' ' . $posting_time["d"] . ' day' . ($posting_time["d"] > 1 ? 's' : '');
}
if ($posting_time["h"]) {
$insight_text .= ' ' . $posting_time["h"] . ' hour' . ($posting_time["h"] > 1 ? 's' : '');
}
if ($posting_time["m"]) {
$insight_text .= ' ' . $posting_time["m"] . ' minute' . ($posting_time["m"] > 1 ? 's' : '');
}
$insight_text .= '</strong> of ' . $this->username . '\'s life.';
return $insight_text;
}
示例2: testSecondsToExactTime
public function testSecondsToExactTime()
{
$minute = 60;
$hour = 60 * $minute;
$day = $hour * 24;
$week = $day * 7;
$result = array('d' => 0, 'h' => 0, 'm' => 0, 's' => 1);
$this->assertEqual($result, TimeHelper::secondsToExactTime(1));
$result = array('d' => 0, 'h' => 0, 'm' => 0, 's' => 0);
$this->assertEqual($result, TimeHelper::secondsToExactTime(0));
$result = array('d' => 0, 'h' => 0, 'm' => 0, 's' => 11);
$this->assertEqual($result, TimeHelper::secondsToExactTime(11));
$result = array('d' => 0, 'h' => 0, 'm' => 1, 's' => 11);
$this->assertEqual($result, TimeHelper::secondsToExactTime(60 + 11));
$result = array('d' => 0, 'h' => 0, 'm' => 6, 's' => 11);
$this->assertEqual($result, TimeHelper::secondsToExactTime(60 * 6 + 11));
$result = array('d' => 0, 'h' => 1, 'm' => 6, 's' => 11);
$this->assertEqual($result, TimeHelper::secondsToExactTime(60 * 60 + 60 * 6 + 11));
$result = array('d' => 0, 'h' => 23, 'm' => 6, 's' => 11);
$this->assertEqual($result, TimeHelper::secondsToExactTime(23 * (60 * 60) + 60 * 6 + 11));
$result = array('d' => 2, 'h' => 0, 'm' => 6, 's' => 11);
$this->assertEqual($result, TimeHelper::secondsToExactTime(48 * (60 * 60) + 60 * 6 + 11));
}
示例3: getPostingTime
public function getPostingTime($total_posts)
{
$posting_seconds = $total_posts * 15;
$time_array = array();
$posting_time = TimeHelper::secondsToExactTime($posting_seconds);
if ($posting_time["d"]) {
$time_array[] = $posting_time["d"] . ' day' . ($posting_time["d"] > 1 ? 's' : '');
}
if ($posting_time["h"]) {
$time_array[] = $posting_time["h"] . ' hour' . ($posting_time["h"] > 1 ? 's' : '');
}
if ($posting_time["m"]) {
$time_array[] = $posting_time["m"] . ' minute' . ($posting_time["m"] > 1 ? 's' : '');
}
return $this->makeList($time_array);
}