bbp_get_topic_post_date

Return the post date and time of a topic.

Description

(string) bbp_get_topic_post_date( (int) $topic_id = 0, (constant) $humanize = false, (bool) $gmt = false ); 

Returns (string)

Parameters (3)

0. $topic_id — Optional. (int)
Topic id.
1. $humanize — Optional. (constant) => false
Humanize output using time_since
2. $gmt — Optional. (bool) => false
Use GMT

Usage

  1. if ( !function_exists( 'bbp_get_topic_post_date' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4. // Optional. Topic id. 
  5. $topic_id = -1; 
  6.  
  7. // Optional. Humanize output using time_since 
  8. $humanize = false; 
  9.  
  10. // Optional. Use GMT 
  11. $gmt = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bbp_get_topic_post_date($topic_id, $humanize, $gmt); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/topics/template.php  
  1. function bbp_get_topic_post_date( $topic_id = 0, $humanize = false, $gmt = false ) { 
  2. $topic_id = bbp_get_topic_id( $topic_id ); 
  3.  
  4. // 4 days, 4 hours ago 
  5. if ( !empty( $humanize ) ) { 
  6. $gmt_s = !empty( $gmt ) ? 'U' : 'G'; 
  7. $date = get_post_time( $gmt_s, $gmt, $topic_id ); 
  8. $time = false; // For filter below 
  9. $result = bbp_get_time_since( $date ); 
  10.  
  11. // August 4, 2012 at 2:37 pm 
  12. } else { 
  13. $date = get_post_time( get_option( 'date_format' ), $gmt, $topic_id, true ); 
  14. $time = get_post_time( get_option( 'time_format' ), $gmt, $topic_id, true ); 
  15. $result = sprintf( _x( '%1$s at %2$s', 'date at time', bbpress ), $date, $time ); 
  16.  
  17. return apply_filters( 'bbp_get_topic_post_date', $result, $topic_id, $humanize, $gmt, $date, $time );