Archived topic
Change comment date's format
3 replies · Started by Allen on November 23, 2021
hi
i searched and found this code snippet that changed the comment's date format.
However after activated, it showed current date instead of comment's published date.
Can I know what might be the problem?
Thank you!
add_filter( 'get_comment_date', 'wpsites_change_comment_date_format' );
function wpsites_change_comment_date_format( $d ) {
$d = date_i18n("Y n j D");
return $d;
}
Hi Allen,
Try this one instead:
add_filter( 'get_comment_date', 'wpsites_change_comment_date_format',10, 3 );
function wpsites_change_comment_date_format( $date, $d, $comment) {
return mysql2date("Y n j D", $comment -> comment_date);
}
Thanks Ying! Work perfectly!
Glad to hear that :)
You are welcome!