wpseek.com
A WordPress-centric search engine for devs and theme authors



get_comment_date › WordPress Function

Since1.5.0
Deprecatedn/a
› get_comment_date ( $format = '', $comment_id = 0 )
Parameters: (2)
  • (string) $format Optional. PHP date format. Defaults to the 'date_format' option.
    Required: No
    Default: (empty)
  • (int|WP_Comment) $comment_id Optional. WP_Comment or ID of the comment for which to get the date. Default current comment.
    Required: No
    Default: —
Returns:
  • (string|int|false) The comment's date. Integer if `$format` is 'U' or 'G', string otherwise.
    False on failure.
Defined at:
Codex:
Change Log:
  • 4.4.0

Retrieves the comment date of the current comment.



Source

function get_comment_date( $format = '', $comment_id = 0 ) {
	$comment = get_comment( $comment_id );

	if ( null === $comment ) {
		// For backward compatibility, failures go through the filter below.
		$comment_date = false;
	} else {
		$_format = ! empty( $format ) ? $format : get_option( 'date_format' );

		$comment_date = mysql2date( $_format, $comment->comment_date );
	}

	/**
	 * Filters the returned comment date.
	 *
	 * @since 1.5.0
	 *
	 * @param string|int|false $comment_date Formatted date string or Unix timestamp. False on failure.
	 * @param string           $format       PHP date format.
	 * @param WP_Comment|null  $comment      The comment object, or null if it does not exist.
	 */
	return apply_filters( 'get_comment_date', $comment_date, $format, $comment );
}