wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_comment_time › WordPress Function

Seit1.5.0
Veraltetn/v
get_comment_time ( $format = '', $gmt = false, $translate = true, $comment_id = 0 )
Parameter: (4)
  • (string) $format Optional. PHP date format. Defaults to the 'time_format' option.
    Erforderlich: Nein
    Standard: (leer)
  • (bool) $gmt Optional. Whether to use the GMT date. Default false.
    Erforderlich: Nein
    Standard: false
  • (bool) $translate Optional. Whether to translate the time (for use in feeds). Default true.
    Erforderlich: Nein
    Standard: true
  • (int|WP_Comment) $comment_id Optional. WP_Comment or ID of the comment for which to get the time. Default current comment.
    Erforderlich: Nein
    Standard:
Gibt zurück:
  • (string) The formatted time.
Definiert in:
Codex:
Changelog:
  • 6.2.0

Retrieves the comment time of the current comment.



Quellcode

function get_comment_time( $format = '', $gmt = false, $translate = true, $comment_id = 0 ) {
	$comment = get_comment( $comment_id );

	if ( null === $comment ) {
		return '';
	}

	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;

	$_format = ! empty( $format ) ? $format : get_option( 'time_format' );

	$comment_time = mysql2date( $_format, $comment_date, $translate );

	/**
	 * Filters the returned comment time.
	 *
	 * @since 1.5.0
	 *
	 * @param string|int $comment_time The comment time, formatted as a date string or Unix timestamp.
	 * @param string     $format       PHP date format.
	 * @param bool       $gmt          Whether the GMT date is in use.
	 * @param bool       $translate    Whether the time is translated.
	 * @param WP_Comment $comment      The comment object.
	 */
	return apply_filters( 'get_comment_time', $comment_time, $format, $gmt, $translate, $comment );
}