當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TimeHelper::secondsToExactTime方法代碼示例

本文整理匯總了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;
 }
開發者ID:pepeleproso,項目名稱:ThinkUp,代碼行數:23,代碼來源:timespent.php

示例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));
 }
開發者ID:pepeleproso,項目名稱:ThinkUp,代碼行數:23,代碼來源:TestOfTimeHelper.php

示例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);
 }
開發者ID:bshruti7,項目名稱:ThinkUp,代碼行數:16,代碼來源:eoytotalposts.php


注:本文中的TimeHelper::secondsToExactTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。