get_comment_date

Retrieve the comment date of the current comment.

Description

(string) get_comment_date( (string) $d = '', (int) $comment_ID = 0 ); 

Returns (string)

The comment's date.

Parameters (2)

0. $d — Optional. (string) => ''
The format of the date. Default user's setting.
1. $comment_id (int)
WP_Comment or ID of the comment for which to get the date. Default current comment.

Usage

  1. if ( !function_exists( 'get_comment_date' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // Optional. The format of the date. Default user's setting. 
  5. $d = ''; 
  6.  
  7. // WP_Comment or ID of the comment for which to get the date. 
  8. // Default current comment. 
  9. $comment_id = -1; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = get_comment_date($d, $comment_id); 
  13.  

Defined (1)

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

/wp-includes/comment-template.php  
  1. function get_comment_date( $d = '', $comment_ID = 0 ) { 
  2. $comment = get_comment( $comment_ID ); 
  3. if ( '' == $d ) 
  4. $date = mysql2date(get_option('date_format'), $comment->comment_date); 
  5. else 
  6. $date = mysql2date($d, $comment->comment_date); 
  7. /** 
  8. * Filters the returned comment date. 
  9. * @since 1.5.0 
  10. * @param string|int $date Formatted date string or Unix timestamp. 
  11. * @param string $d The format of the date. 
  12. * @param WP_Comment $comment The comment object. 
  13. */ 
  14. return apply_filters( 'get_comment_date', $date, $d, $comment );