get_comment_date example

?> </td> </tr> <tr> <th scope="row"><?php _e( 'Submitted on' ); ?></th> <td> <?php         $submitted = sprintf(
            /* translators: 1: Comment date, 2: Comment time. */
            __( '%1$s at %2$s' ),
            /* translators: Comment date format. See https://www.php.net/manual/datetime.format.php */
            get_comment_date( __( 'Y/m/d' )$comment ),
            /* translators: Comment time format. See https://www.php.net/manual/datetime.format.php */
            get_comment_date( __( 'g:i a' )$comment )
        );
        if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
            echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
        } else {
            echo $submitted;
        }
        ?> </td> </tr> <tr> <th scope="row">
/** * Displays the comment date of the current comment. * * @since 0.71 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object. * * @param string $format Optional. PHP date format. Defaults to the 'date_format' option. * @param int|WP_Comment $comment_id WP_Comment or ID of the comment for which to print the date. * Default current comment. */
function comment_date( $format = '', $comment_id = 0 ) {
    echo get_comment_date( $format$comment_id );
}

/** * Retrieves the excerpt of the given comment. * * Returns a maximum of 20 words with an ellipsis appended if necessary. * * @since 1.5.0 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object. * * @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the excerpt. * Default current comment. * @return string The possibly truncated comment excerpt. */
<?php endif; ?> <div class="comment-meta commentmetadata"> <?php             printf(
                '<a href="%s">%s</a>',
                esc_url( get_comment_link( $comment$args ) ),
                sprintf(
                    /* translators: 1: Comment date, 2: Comment time. */
                    __( '%1$s at %2$s' ),
                    get_comment_date( '', $comment ),
                    get_comment_time()
                )
            );

            edit_comment_link( __( '(Edit)' ), ' &nbsp;&nbsp;', '' );
            ?> </div> <?php         comment_text(
            $comment,
            
return '';
    }

    $comment = get_comment( $block->context['commentId'] );
    if ( empty( $comment ) ) {
        return '';
    }

    $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';

    $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
    $formatted_date     = get_comment_date(
        isset( $attributes['format'] ) ? $attributes['format'] : '',
        $comment
    );
    $link               = get_comment_link( $comment );

    if ( ! empty( $attributes['isLink'] ) ) {
        $formatted_date = sprintf( '<a href="%1s">%2s</a>', esc_url( $link )$formatted_date );
    }

    return sprintf(
        '<div %1$s><time datetime="%2$s">%3$s</time></div>',
        
$list_items_markup .= sprintf(
                /* translators: 1: author name (inside <a> or <span> tag, based on if they have a URL), 2: post title related to this comment */
                __( '%1$s on %2$s' ),
                $author_markup,
                $post_title
            );

            if ( $attributes['displayDate'] ) {
                $list_items_markup .= sprintf(
                    '<time datetime="%1$s" class="wp-block-latest-comments__comment-date">%2$s</time>',
                    esc_attr( get_comment_date( 'c', $comment ) ),
                    date_i18n( get_option( 'date_format' )get_comment_date( 'U', $comment ) )
                );
            }
            $list_items_markup .= '</footer>';
            if ( $attributes['displayExcerpt'] ) {
                $list_items_markup .= '<div class="wp-block-latest-comments__comment-excerpt">' . wpautop( get_comment_excerpt( $comment ) ) . '</div>';
            }
            $list_items_markup .= '</article></li>';
        }
    }

    

    }

    /** * @param WP_Comment $comment The comment object. */
    public function column_date( $comment ) {
        $submitted = sprintf(
            /* translators: 1: Comment date, 2: Comment time. */
            __( '%1$s at %2$s' ),
            /* translators: Comment date format. See https://www.php.net/manual/datetime.format.php */
            get_comment_date( __( 'Y/m/d' )$comment ),
            /* translators: Comment time format. See https://www.php.net/manual/datetime.format.php */
            get_comment_date( __( 'g:i a' )$comment )
        );

        echo '<div class="submitted-on">';

        if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
            printf(
                '<a href="%s">%s</a>',
                esc_url( get_comment_link( $comment ) ),
                $submitted
            );
Home | Imprint | This part of the site doesn't use cookies.