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


PHP distance_of_time_in_words函数代码示例

本文整理汇总了PHP中distance_of_time_in_words函数的典型用法代码示例。如果您正苦于以下问题:PHP distance_of_time_in_words函数的具体用法?PHP distance_of_time_in_words怎么用?PHP distance_of_time_in_words使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_distance_of_time_in_words

 function test_distance_of_time_in_words()
 {
     // seconds
     $this->assertEqual('less than 5 seconds', distance_of_time_in_words(0, 0, true));
     $this->assertEqual('less than 5 seconds', distance_of_time_in_words(3, 0, true));
     $this->assertEqual('less than 10 seconds', distance_of_time_in_words(5, 0, true));
     $this->assertEqual('less than 10 seconds', distance_of_time_in_words(7, 0, true));
     $this->assertEqual('less than 20 seconds', distance_of_time_in_words(10, 0, true));
     $this->assertEqual('less than 20 seconds', distance_of_time_in_words(15, 0, true));
     $this->assertEqual('half a minute', distance_of_time_in_words(20, 0, true));
     $this->assertEqual('half a minute', distance_of_time_in_words(30, 0, true));
     $this->assertEqual('less than a minute', distance_of_time_in_words(40, 0, true));
     $this->assertEqual('less than a minute', distance_of_time_in_words(50, 0, true));
     // minutes
     $this->assertEqual('less than a minute', distance_of_time_in_words(0, 0));
     $this->assertEqual('less than a minute', distance_of_time_in_words(40, 0));
     $this->assertEqual('less than a minute', distance_of_time_in_words(0, 40));
     $this->assertEqual('less than a minute', distance_of_time_in_words(-40, 0));
     $this->assertEqual('less than a minute', distance_of_time_in_words(0, -40));
     $this->assertEqual('1 minute', distance_of_time_in_words(60, 0));
     $this->assertEqual('1 minute', distance_of_time_in_words(90, 0));
     $this->assertEqual('2 minutes', distance_of_time_in_words(120, 0));
     $this->assertEqual('20 minutes', distance_of_time_in_words(20 * 60, 0));
     $this->assertEqual('about 1 hour', distance_of_time_in_words(50 * 60, 0));
     $this->assertEqual('about 2 hours', distance_of_time_in_words(100 * 60, 0));
     $this->assertEqual('about 20 hours', distance_of_time_in_words(20 * 60 * 60, 0));
     $this->assertEqual('about 21 hours', distance_of_time_in_words(20 * 60 * 60 + 30 * 60, 0));
     $this->assertEqual('1 day', distance_of_time_in_words(24 * 60 * 60, 0));
     $this->assertEqual('1 day', distance_of_time_in_words(40 * 60 * 60, 0));
     $this->assertEqual('2 days', distance_of_time_in_words(48 * 60 * 60, 0));
     $this->assertEqual('about 1 month', distance_of_time_in_words(30 * 24 * 60 * 60, 0));
     $this->assertEqual('2 months', distance_of_time_in_words(60 * 24 * 60 * 60, 0));
     $this->assertEqual('about 1 year', distance_of_time_in_words(365 * 24 * 60 * 60, 0));
     $this->assertEqual('over 3 years', distance_of_time_in_words(3 * 365 * 24 * 60 * 60, 0));
 }
开发者ID:nebirhos,项目名称:wordless,代码行数:35,代码来源:date_helper_test.php

示例2: getPublishingTime

 /**
  * This method returns the minuts/hours/day since publishing of this social object
  *
  * @author Christian Schätzle
  */
 public function getPublishingTime()
 {
     $lSocialObjectDate = $this->getC();
     sfProjectConfiguration::getActive()->loadHelpers(array('Date'));
     $lDate = distance_of_time_in_words($lSocialObjectDate);
     return $lDate;
 }
开发者ID:42medien,项目名称:spreadly,代码行数:12,代码来源:SocialObject.php

示例3: twitterBadge

function twitterBadge($userEmail, $userPassword, $count = 4)
{
    $json = new Services_JSON();
    // Create the twitter Cacher object to pull feed
    // Password is needed in case feed is protected
    // HTTP Basic Auth hasn't been deprecated...yet...so...lazy wins for now
    $tc = new TwitterCacher($userEmail, $userPassword);
    $tc->setUserAgent("Mozilla/5.0 (compatible; TwitterCacher/1.0; +http://www.kolich.com)");
    //echo '<!-- ' . $tc->getUserTimeline(4) . ' -->';
    //Create a timeline object of the feed (pull from live if old)
    $timeline = $json->decode($tc->getUserTimeline($count));
    if (!$timeline) {
        return '<p>Error locating tweets.</p>';
    }
    // Create unorderer list of tweets (see gagawa module)
    $ul = new Ol();
    foreach ($timeline as $tweet) {
        $text = $tweet->text;
        //Format date as 5 min ago, 2 hours ago, etc.
        $date = distance_of_time_in_words(strtotime($tweet->created_at)) . ' ago';
        // Tweet source, i.e. twhril, tweetie, tweetdeck, etc.
        // $source = $tweet->source;
        // Generate direct link to tweet
        $tweetid = $tweet->id;
        $screenname = $tweet->user->screen_name;
        $tweetlink = 'http://twitter.com/' . $screenname . '/status/' . $tweetid;
        // Turn links into links
        $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)', '<a href="\\1" target="_blank">\\1</a>', $text);
        // Turn twitter @username into links to the users Twitter page
        $text = preg_replace('/(^|\\s)@(\\w+)/', '\\1<a href="http://www.twitter.com/\\2">@\\2</a>', $text);
        // Turn #hashtags into searches
        $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2">#\\2</a>', $text);
        // Personal Formatting, see Gagawa for documentaiton.
        // <li>Tweet Text <span>(<a href="linktotweet">some time ago</a>)<span></li>
        $li = new Li();
        $ul->appendChild($li);
        $li->appendChild(new Text($text . ' ('));
        $span = new Span();
        $link = new A();
        $link->setHref($tweetlink);
        $link->appendChild(new Text($date));
        $span->appendChild($link);
        $li->appendChild($span);
        $li->appendChild(new Text(')'));
    }
    //end foreach( $timeline as $tweet )
    // Returns the stack of li's enclosed by ul
    return $ul->write();
}
开发者ID:bobbyearl,项目名称:bobbyearl.github.io,代码行数:49,代码来源:twitter-badge.php

示例4: wrapTweets

function wrapTweets($timeline)
{
    if (!$timeline) {
        return '<p>Unable to connect to twitter.</p>';
    }
    // Create unorderer list of tweets (see gagawa module)
    $ul = new Ol();
    foreach ($timeline as $tweet) {
        $text = $tweet->text;
        //Format date as 5 min ago, 2 hours ago, etc.
        $date = distance_of_time_in_words(strtotime($tweet->created_at)) . ' ago';
        // Tweet source, i.e. twhril, tweetie, tweetdeck, etc.
        // $source = $tweet->source;
        // Generate direct link to tweet
        $tweetid = $tweet->id;
        $screenname = $tweet->user->screen_name;
        $tweetlink = 'http://twitter.com/' . $screenname . '/status/' . $tweetid;
        // Turn links into links
        $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)', '<a href="\\1" target="_blank">\\1</a>', $text);
        // Turn twitter @username into links to the users Twitter page
        $text = preg_replace('/(^|\\s)@(\\w+)/', '\\1<a href="http://www.twitter.com/\\2" target="_blank">@\\2</a>', $text);
        // Turn #hashtags into searches
        $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2" target="_blank">#\\2</a>', $text);
        // Personal Formatting, see Gagawa for documentaiton.
        // <li>Tweet Text <span>(<a href="linktotweet">some time ago</a>)<span></li>
        $li = new Li();
        $ul->appendChild($li);
        $span = new Span();
        $link = new A();
        $link->setHref($tweetlink);
        $link->appendChild(new Text($date));
        $span->appendChild($link);
        //$li->appendChild($span);
        $li->appendChild(new Text($text));
    }
    //end foreach( $timeline as $tweet )
    // Returns the stack of li's enclosed by ul
    return $ul->write();
}
开发者ID:bobbyearl,项目名称:bobbyearl.github.io,代码行数:39,代码来源:twitter.php

示例5: strtolower

            ?>
" title="<?php 
            echo $d->getTitle();
            ?>
">
                          <i class=" icone-rede <?php 
            echo strtolower($d->getDescription());
            ?>
 pull-right"></i>
                        </a>
                        <div class="">
                          <h5><?php 
            echo $d->getTitle();
            ?>
 <small><br/><?php 
            echo distance_of_time_in_words(strtotime($d->AssetContent->getHeadlineShort()), NULL, TRUE);
            ?>
</small></h5>
                        </div>
                        <img src="<?php 
            echo $d->AssetContent->getHeadline();
            ?>
" alt="<?php 
            echo $d->getTitle();
            ?>
" class="avatar pull-left">
                        <p><?php 
            echo html_entity_decode($d->AssetContent->render());
            ?>
</p>
                        <!--<a href="<?php 
开发者ID:GustavoAdolfo,项目名称:cmais-frontend-2,代码行数:31,代码来源:playlist3Success.php

示例6: link_to

' alt='avatar'/></td>
            		<td><?php 
    echo link_to(h($package->user->username . '/' . $package->name), url_for("PackageController", 'show', $package->user->username, $package->name));
    ?>
</td>
							</tr>
						</table>
        </td>
        <td><span class='small'><?php 
    echo $version->summary;
    ?>
</span></td>
        <td><?php 
    echo $version->min_php;
    ?>
</td>
        <td><span class='small'><?php 
    echo distance_of_time_in_words(DateHelper::from_db($package->updated_at), time(), true);
    ?>
 ago</span></td>
      </tr>
    <?php 
}
?>
  </tbody>
</table>
<div id='pagination'>
	<?php 
echo paginate($packages);
?>
</div>
开发者ID:xetorthio,项目名称:pearfarm_channel_server,代码行数:31,代码来源:_packages.php

示例7: simple_format_text

    <?php 
echo simple_format_text($forum->getDescription(), array('class' => 'forum_description'));
?>
  </td>
  <td class="forum_threads"><?php 
echo $forum->getNbTopics();
?>
</td>
  <td class="forum_posts"><?php 
echo $forum->getNbPosts();
?>
</td>
  <td class="forum_recent">
    <?php 
if ($forum->getLatestPostId()) {
    ?>
      <?php 
    $latest_post = $forum->getsfSimpleForumPost();
    ?>
      <?php 
    echo link_to($latest_post->getTitle(), '@show_forum_post?id=' . $latest_post->getId() . '&project=' . $project->getSlug() . '&forum_name=' . $latest_post->getsfSimpleforumForum()->getStrippedName());
    ?>
<br />
      <?php 
    echo __('%date% ago by %author%', array('%date%' => distance_of_time_in_words($latest_post->getCreatedAt('U')), '%author%' => get_partial('forums/author_name', array('author' => $latest_post->getAuthorName(), 'sf_cache_key' => $latest_post->getAuthorName()))));
    ?>
    <?php 
}
?>
  </td>
</tr>
开发者ID:sgrove,项目名称:cothinker,代码行数:31,代码来源:_forum.php

示例8: print_preRegistration

function print_preRegistration()
{
    global $player;
    $events = Event::getNextPreRegister();
    echo "<table><tr><td colspan=\"3\"><b>PREREGISTER FOR EVENTS</b></td></tr>";
    if (count($events) == 0) {
        echo "<tr><td colspan=\"3\"> No Upcoming Events! </td> </tr>";
    }
    foreach ($events as $event) {
        echo "<tr><td>{$event->name}</td>";
        echo "<td>" . distance_of_time_in_words(time(), strtotime($event->start)) . "</td>";
        if ($event->hasRegistrant($player->name)) {
            echo "<td>Registered <a href=\"prereg.php?action=unreg&event=" . urlencode($event->name) . "\">(Unreg)</a></td>";
        } else {
            echo "<td><a href=\"prereg.php?action=reg&event=" . urlencode($event->name) . "\">Register</a></td>";
        }
        echo "</tr>";
    }
    echo "</table>";
}
开发者ID:jamuraa,项目名称:gatherling,代码行数:20,代码来源:player.php

示例9: simple_format_text

    <?php 
echo simple_format_text($forum->getDescription(), array('class' => 'forum_description'));
?>
  </td>
  <td class="forum_threads"><?php 
echo $forum->getNbTopics();
?>
</td>
  <td class="forum_posts"><?php 
echo $forum->getNbPosts();
?>
</td>
  <td class="forum_recent">
    <?php 
if ($forum->getLatestPostId()) {
    ?>
      <?php 
    $latest_post = $forum->getsfSimpleForumPost();
    ?>
      <?php 
    echo link_to($latest_post->getTitle(), 'sfSimpleForum/post?id=' . $latest_post->getId());
    ?>
<br />
      <?php 
    echo __('%date% ago by %author%', array('%date%' => distance_of_time_in_words($latest_post->getCreatedAt('U')), '%author%' => link_to(get_partial('sfSimpleForum/author_name', array('author' => $latest_post->getAuthorName(), 'sf_cache_key' => $latest_post->getAuthorName())), 'sfSimpleForum/userLatestPosts?username=' . $latest_post->getAuthorName())), 'sfSimpleForum');
    ?>
    <?php 
}
?>
  </td>
</tr>
开发者ID:kriswallsmith,项目名称:sfSimpleForumPlugin,代码行数:31,代码来源:_forum.php

示例10: link_to

?>
"></a>
  
  <div id="comment_content">
    <div id="author_and_date">
		<?php 
$poster = $comment->getCommenterName();
?>
		<?php 
$posted_by = $comment->getCommenterLink() ? link_to($poster, $comment->getCommenterLink()) : $poster;
?>
      posted by <?php 
echo $posted_by;
?>
 <?php 
echo distance_of_time_in_words(strtotime($comment->getCreatedAt()));
?>
 ago.
    </div>
  
    <div id="body">
      <?php 
echo nl2br($comment->getBody());
?>
    </div>
  
    <?php 
if (sfConfig::get('app_comments_nesting')) {
    ?>
      <div id="links">
        <?php 
开发者ID:bshaffer,项目名称:Symplist,代码行数:31,代码来源:_comment_row.php

示例11: link_to

  <div style="float:left;max-width:80%;">
    <h3><?php 
    echo link_to($feature->getId() . '. ' . $feature->getTitle(), 'features/show?feature=' . $feature->getUuid(), array('id' => $feature->getId()));
    ?>
 (<?php 
    echo format_number_choice('[' . sfConfig::get('app_feature_status_closed') . ']Closed|[' . sfConfig::get('app_feature_status_open') . ']Open|[' . sfConfig::get('app_feature_status_implemented') . ']Implemented|[' . sfConfig::get('app_feature_status_fixed') . ']Fixed', array('%1%' => $feature->getStatus()), $feature->getStatus());
    ?>
)<span id="indicator_<?php 
    echo $feature->getUuid();
    ?>
" style="display:none;"><?php 
    echo image_tag('indicator.gif');
    ?>
 Casting Vote...</span></h3>
    <h4><?php 
    echo __('A %type% Suggested by %1% %2% ago, regarding %category%', array('%1%' => link_to($feature->getsfGuardUser()->getProfile(), '@show_user?user=' . $feature->getsfGuardUser()->getProfile()->GetUuid()), '%2%' => distance_of_time_in_words($feature->getCreatedAt('U')), '%type%' => format_number_choice('[' . sfConfig::get('app_feature_type_bug') . ']Bug Report|[' . sfConfig::get('app_feature_type_feature') . ']Feature Request', array(), $feature->getType()), '%category%' => $feature->getCategoryInWords()));
    ?>
</h4>
    <p><?php 
    echo $feature->getDescription();
    ?>
</p>
  </div>
  <hr class="clear" />
</div>
<?php 
}
?>
<hr class="clear" />

开发者ID:sgrove,项目名称:cothinker,代码行数:29,代码来源:listSuccess.php

示例12: ucwords

	</div>
	<div>
		<?php 
echo ucwords($profile->getTitle());
?>
<br />
		<?php 
echo $profile->getDepartment();
?>
<br />
		<?php 
echo $profile->getCampus();
?>
<br />
		<?php 
echo distance_of_time_in_words($profile->getsfGuardUser()->getLastLogin('U')) . ' ago';
$sf_context->getLogger()->info('checking sfguarduser');
$profile->getsfGuardUser();
$sf_context->getLogger()->info('finished checking...');
//format_date($profile->getSfGuardUser()->getLastLogin())
?>
<br />
	</div>
        <div style="float: right; right:10px; bottom: 10px;display:inline;">
    <?php 
if ($sf_user->isAuthenticated()) {
    ?>
      <?php 
    if ($sf_user->getId() == $profile->getUserId()) {
        ?>
          What...you want to add yourself as a friend?
开发者ID:sgrove,项目名称:cothinker,代码行数:31,代码来源:_profile_main.php

示例13: ucfirst

    Campus:<br />
    Department:<br />
    Updated:<br />
  </div>
  <div>
    <?php 
echo $project->getCampus();
?>
<br />
    <?php 
echo $project->getDepartment();
?>
<br />
    <?php 
$event = $project->getLastUpdated();
echo ucfirst(distance_of_time_in_words($event->getCreatedAt('U')) . ' ago'), ' (' . $event->getCategory() . ')';
?>
<br />
  </div>
  <div style="float: right; right:10px; bottom: 10px;display:inline;">
    <?php 
if ($sf_user->isAuthenticated()) {
    ?>
      <span>Favorite <?php 
    echo link_to_favorite($project, array());
    ?>
</span> |
      <?php 
    if ($sf_user->getProfile()->isSubscribedToHistoryGroup($project->getHistoryGroup()) == false) {
        ?>
        <span>Subscribe <?php 
开发者ID:sgrove,项目名称:cothinker,代码行数:31,代码来源:_widget_project_header.php

示例14: date

$t->is(distance_of_time_in_words($now - 49, $now, true), 'less than a minute', $msg);
$t->is(distance_of_time_in_words($now - 60, $now, true), '1 minute', $msg);

$t->is(distance_of_time_in_words($now - 10 * 60, $now), '10 minutes', $msg);
$t->is(distance_of_time_in_words($now - 50 * 60, $now), 'about 1 hour', $msg);

$t->is(distance_of_time_in_words($now - 3 * 3600, $now), 'about 3 hours', $msg);
$t->is(distance_of_time_in_words($now - 25 * 3600, $now), '1 day', $msg);

$t->is(distance_of_time_in_words($now - 4 * 86400, $now), '4 days', $msg);
$t->is(distance_of_time_in_words($now - 35 * 86400, $now), 'about 1 month', $msg);
$t->is(distance_of_time_in_words($now - 75 * 86400, $now), '3 months', $msg);

$t->is(distance_of_time_in_words($now - 370 * 86400, $now), 'about 1 year', $msg);
$t->is(distance_of_time_in_words($now - 4 * 370 * 86400, $now), 'over 4 years', $msg);
$t->is(distance_of_time_in_words($now - 1000 * 86400, $now), 'over 2 years', $msg);

// format_date()
$t->diag('format_date()');
$context->user->culture = 'fr';
$t->is(format_date(time()), date('d/m/y'), 'format_date() format a numerical date according to the user culture');
$t->is(format_date(date('Y-m-d')), date('d/m/y'), 'format_date() format a string date according to the user culture');
$t->is(format_date(date('y-m-d')), date('d/m/y'), 'format_date() format a string date with two digit year according to the user culture');
$t->is(format_date('1789-07-14'), '14/07/89', 'format_date() formats pre-epoch dates');

$context->user->culture = 'en';
$t->is(format_date($now, 'F'), date('F j, Y g:i:s A', $now).' '.date('T', $now), 'format_date() takes a format string as its second argument');

$context->user->culture = 'fr';
$t->is(format_date($now, 'F', 'en'), date('F j, Y g:i:s A', $now).' '.date('T', $now), 'format_date() takes a culture as its third argument');
开发者ID:nationalfield,项目名称:symfony,代码行数:30,代码来源:DateHelperTest.php

示例15: link_to

    ?>
</div></td>
				<td><?php 
    echo link_to($version->version, url_for("VersionController", 'show', $package->user->username, $package->name, $version->version));
    ?>
</td>
        <td width='25%'><div class='small summary-right'><?php 
    echo $version->summary;
    ?>
</div></td>
        <td><?php 
    echo $version->min_php;
    ?>
</td>
        <td><span class='small'><?php 
    echo distance_of_time_in_words(DateHelper::from_db($version->created_at), time(), true);
    ?>
 ago</span></td>
				<td><?php 
    echo isset($package->rating) ? PackageRating::convert_to_human($package->rating) : 0;
    ?>
%</td>
      </tr>
    <?php 
}
?>
  </tbody>
</table>
<div id='pagination'>
	<?php 
echo paginate($packages);
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:31,代码来源:_packages.php


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