示例#1
0
文件: reply.php 项目: ntwb/bbPress
 /**
  * @covers ::bbp_reply_post_date
  * @covers ::bbp_get_reply_post_date
  */
 public function test_bbp_get_reply_post_date()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $now = time();
     $post_date = date('Y-m-d H:i:s', $now - 60 * 66);
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Configue our written date time, August 4, 2012 at 2:37 pm.
     $gmt = false;
     $date = get_post_time(get_option('date_format'), $gmt, $r, true);
     $time = get_post_time(get_option('time_format'), $gmt, $r, true);
     $result = sprintf('%1$s at %2$s', $date, $time);
     // Output, string, August 4, 2012 at 2:37 pm.
     $this->expectOutputString($result);
     bbp_reply_post_date($r);
     // String, August 4, 2012 at 2:37 pm.
     $datetime = bbp_get_topic_post_date($r, false, false);
     $this->assertSame($result, $datetime);
     // Humanized string, 4 days, 4 hours ago.
     $datetime = bbp_get_topic_post_date($r, true, false);
     $this->assertSame('1 hour, 6 minutes ago', $datetime);
     // Humanized string using GMT formatted date, 4 days, 4 hours ago.
     $datetime = bbp_get_topic_post_date($r, true, true);
     $this->assertSame('1 hour, 6 minutes ago', $datetime);
 }
示例#2
0
/**
 * Output the post date and time of a topic
 *
 * @since 2.2.0 bbPress (r4155)
 *
 * @param int $topic_id Optional. Topic id.
 * @param bool $humanize Optional. Humanize output using time_since
 * @param bool $gmt Optional. Use GMT
 * @uses bbp_get_topic_post_date() to get the output
 */
function bbp_topic_post_date($topic_id = 0, $humanize = false, $gmt = false)
{
    echo bbp_get_topic_post_date($topic_id, $humanize, $gmt);
}
" align="left" />
				</a></div>
			<?php 
}
?>

			<p><a href="<?php 
echo get_permalink($pro);
?>
"><?php 
echo get_the_title($pro);
?>
</a><br/>

			<?php 
$date = bbp_get_topic_post_date();
$cDate = DateTime::createFromFormat('F j, Y \\a\\t g:ia', $date);
?>
			Posted on <?php 
echo $cDate->format('n/j/Y \\a\\t g:ia');
?>
.</p>

		</div>
		<div class="postreply">
			<a href="#" class="replybtn">Reply</a>
		</div>
	</div>
</div>

<?php