get_comment_time

Retrieve the comment time of the current comment.

Description

(string) get_comment_time( (string) $d = '', (constant) $gmt = false, (bool) $translate = true ); 

Returns (string)

The formatted time.

Parameters (3)

0. $d — Optional. (string) => ''
The format of the time. Default user's settings.
1. $gmt — Optional. (constant) => false
Whether to use the GMT date. Default false.
2. $translate — Optional. (bool) => true
Whether to translate the time (for use in feeds). Default true.

Usage

  1. if ( !function_exists( 'get_comment_time' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // Optional. The format of the time. Default user's settings. 
  5. $d = ''; 
  6.  
  7. // Optional. Whether to use the GMT date. Default false. 
  8. $gmt = false; 
  9.  
  10. // Optional. Whether to translate the time (for use in feeds). 
  11. // Default true. 
  12. $translate = true; 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = get_comment_time($d, $gmt, $translate); 
  16.  

Defined (1)

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

/wp-includes/comment-template.php  
  1. function get_comment_time( $d = '', $gmt = false, $translate = true ) { 
  2. $comment = get_comment(); 
  3.  
  4. $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; 
  5. if ( '' == $d ) 
  6. $date = mysql2date(get_option('time_format'), $comment_date, $translate); 
  7. else 
  8. $date = mysql2date($d, $comment_date, $translate); 
  9.  
  10. /** 
  11. * Filters the returned comment time. 
  12. * @since 1.5.0 
  13. * @param string|int $date The comment time, formatted as a date string or Unix timestamp. 
  14. * @param string $d Date format. 
  15. * @param bool $gmt Whether the GMT date is in use. 
  16. * @param bool $translate Whether the time is translated. 
  17. * @param WP_Comment $comment The comment object. 
  18. */ 
  19. return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );