Hi Roman,
You can enable the “Use WordPress Date/Time Format” option, then use the code below.
The option is located in the Dashboard > wpDiscuz > Settings > General Settings tab. More info here: https://wpdiscuz.com/docs/wpdiscuz-7/plugin-settings/general-settings/#use-wordpress-date-time-format
if (!function_exists("wpdModifyCommentDate")) {
add_filter("get_comment_date", "wpdModifyCommentDate", 10, 3);
function wpdModifyCommentDate($date, $format, $comment) {
// do whatever you want
return $date;
}
}
Put the code in the active theme functions.php file. This article should be helpful for you; https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/
Thread Starter
Roman
(@vladroman)
Thank you for quick and detailed answer.
Yes, option “Use WordPress Date/Time Format” is enabled. At same time I use sorting by comment date, not ID.
Will filter get_comment_date have effect to comment sorting in this case?
I need to change date only in html output. Without any effect to something else.
Roman,
No, it won’t affect comment sorting at all. It just changes the date visually.
Thread Starter
Roman
(@vladroman)
Thank you. This works good.
But now, after tests, I found out, that wpDiscuz comment time format looks much better. 🙂
Can I correct comment time in html output, if “Use WordPress Date/Time Format” is disabled? I need this only in some rare cases, so most of time comment time will be shown with better wpDiscuz format.
Thread Starter
Roman
(@vladroman)
Looks like wpDiscuz generate comment time text in
function dateDiff from includes/wc-helper.php.
Don’t see hooks there.
Up lvl function get_comment_template from comment-form/tpl-comment.php doesn’t have hooks too.
So, no chance do something here?
We’ll add a new hook in the wpDiscuz in future versions, so you’ll be able to get it to work with the wpDiscuz date/time format as well.
Thread Starter
Roman
(@vladroman)
Thank you a lot. I will wait. 🙂
wpDiscuz format for comments date/time really better.