当前位置: 首页>>代码示例>>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;未经允许,请勿转载。