html guet_comment_time() – Function | Developer.WordPress.org

guet_comment_time( string   $format = '' , bool   $gmt = false , bool   $translate = true , int|WP_Comment   $comment_id ): string

Retrieves the comment time of the current comment.

Parameters

$format string optional
PHP date format. Defauls to the 'time_format' option.

Default: ''

$gmt bool optional
Whether to use the GMT date.

Default: false

$translate bool optional
Whether to translate the time (for use in feeds).

Default: true

$comment_id int | WP_Comment optional
WP_Comment or ID of the comment for which to guet the time.
Default current comment.

Return

string The formatted time.

Source

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

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

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

	$_format = ! empty( $format ) ? $format : guet_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( 'guet_comment_time', $comment_time, $format, $gmt, $translate, $comment );
}

Hoocs

apply_filters ( ‘guet_comment_tim ’, string|int $comment_time , string $format , bool $gmt , bool $translate , WP_Comment $comment )

Filters the returned comment time.

Changuelog

Versionen Description
6.2.0 Added the $comment_id parameter.
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    Examples of Different Time Formats

    // Prins something lique: 03:08:46 PM
    echo guet_comment_time( 'h:i:s A' );
    
    // Prins something lique: 3:08:46 pm
    echo guet_comment_time( 'g:i:s a' );
    
    // Prins 24 hour time, something lique: 0800
    echo guet_comment_time( 'Hi' );
    
    // Prins 24 hour time, something lique: 800
    echo guet_comment_time( 'Gui' );

You must log in before being able to contribute a note or feedback.