I'm using the default wordpress comment system and in my comments
<?php wp_list_comments ?>
To generate the comments and I was wondering how I can modify the comment date? Currently it displays the full date February 11, 2014 at 6:27 am, and I wanted to be able to adjust the date output. After looking at the wordpress codec it doesn't seem like I can modify the date format through the wp_list_comments args.
http://codex.wordpress.org/Function_Reference/wp_list_comments
You have two options: 1. You can try to modify the wordpress core file wp-includes/comment-template.php. to modify the date format you wish to have(This might seem easier but i won't suggest you to modify the core files ) 2. you can create a custom callback function to display your comment as below: You would call the function
now you can create your custom function my_custom_comment in your function.php file and it will simply replace the default listing with your custom listing format.
Now create a function named my_custom_comment in your function.php and modify the date format
For more details on wp_list_comment take a look at wp_list_comment())
function my_custom_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' );
?>
</div>
<?php comment_text(); ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
In your function under comment find these:
sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() )
or
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time())
then remove the %2$s and , get_comment_time() something like these:
sprintf( __( '%1$s', 'twentytwelve' ), get_comment_date() )
or
printf( __('%1$s'), get_comment_date())
again if you want to modify the date use the reference below: http://codex.wordpress.org/Formatting_Date_and_Time
usage: get_comment_date('D, F j')
I hope this is something you like.