The code below is the comments template from my functions.php in WP. It outputs comments with a reply link to every comment. When someone replies to a comment it says
“In reply to Name of comment author + Comment date”
below the comment text. Clicking that link, which I for simplicity’s sake call the “comment-reply-link”, gets you back to the original comment. So far all is well.
The date of every comment displays correctly in the format I have chosen (‘M j Y H:i’), which is in the first printf function. A comment date will display in the following format “Feb 10 2012 10:35” The date in the “comment-reply-link”, however, displays in a completely different date format: 2012-02-10 10:35:17. As you can see, it also displays seconds.
The last printf function in the code below outputs the “comment-reply-link”. I don’t know where the inconsistent format comes from. It’s not in my settings in the admin panel nor can I find it in the comments-template.php. The only place where the incorrect format is also displayed is in the comment_date column in the comments table when I open the database in phpmyadmin.
Would be very grateful if someone could help me get the “comment-reply-link” in the same date format as the comments themselves (‘M j Y H:i’).
function mytheme_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata">
<div class="commenter-info"><span class="commenter"><?php printf( __( '%s', 'mytheme' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?><br/></span><!-- commenter -->
<div class="comment-date"><?php
/* translators: 1: date, 2: time */
printf( __( '%1$s', 'mytheme' ), get_comment_date('M j Y H:i') ); ?><?php edit_comment_link( __( 'Edit →', 'mytheme' ), ' ' );
?></div><!-- comment-date -->
</div><!-- commenter-info -->
<div class="comment-gravatar"><?php echo get_avatar( $comment, 65 ); ?></div>
<span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<a class="comment-reply-link" href="?replytocom=<?php comment_ID(); ?>#respond" onclick="return addComment.moveForm('comment-<?php comment_ID(); ?>', '<?php comment_ID(); ?>', 'respond', '<?php echo $post->ID; ?>')">Reply</a>
</span><!-- reply -->
</div><!-- .comment-meta .commentmetadata -->
<div class="comment-content">
<?php comment_text(); ?>
</div><!-- comment-content -->
<?php
if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
printf( '<span id="replyto">In reply to <a href="%1$s">%2$s %3$s</a></span>', $parent_link, $parent->comment_author, $parent->comment_date );
} ?>
<?php if ( $comment->comment_approved == '0' ) : ?>
<p class="moderation"><?php _e( 'Your comment is moderated', 'mytheme' ); ?></p>
<?php endif; ?>
</div><!-- comment-body-->
</div><!-- #comment-## -->
It looks like you need to reformat the
$parent->comment_date.Try adding this:
Before: