Hello!
I want to display the date of the comments as “X hours ago / X days ago” rather than “Month/Day/Year”. In order to do so, I installed the plugin “Time Ago” by MEKS.
However, I get this error message:
date() expects parameter 2 to be integer, string given in /home/alber870/public_html/wp-content/themes/Newspaper/includes/wp_booster/td_module_single_base.php on line 290
Line 290 of the code reads this:
$buffy .= ‘<time class=”entry-date updated td-module-date’ . $visibility_class . ‘” datetime=”‘ . date(DATE_W3C, $td_article_date_unix)
I contacted MEKS regarding this issue and they recommended contacting TagDiv support since they said it has to do with the Newspaper theme and the WordPress standard human_time_diff() function: https://codex.wordpress.org/Function_Reference/human_time_diff.
How can I fix it? Thanks again for your help!
Hello,
I can’t say for sure about the plugin but since you already have to make modification in the code to make the plugin work, you might as well code the time ago and not use any plugin at all for it. Please use this guide: https://forum.tagdiv.com/topic/changing-the-date-to-x-time-ago/
Thanks.
Hello,
The function presented there is meant for posts, not comments. That is why it will not work properly on comments. You will have to adapt the code in order for it to work properly on comments .
Add this code:
<?php printf( _x( '%s ago', '%s = human-readable time difference', 'your-text-domain' ), human_time_diff( get_comment_time( 'U' ), current_time( 'timestamp' ) ) ); ?>
Like so: https://www.screencast.com/t/EIkDG4cR1
result: https://www.screencast.com/t/kuKy2Kkhv6SF
Thanks.
Sorry for not explaining properly. I meant to say that all the blog posts showed 5 days ago. Today, all of them, even the new ones say “6 days ago” like this:

This is the code that I have for module 1. Is there something missing?:
<?php
class td_module_1 extends td_module {
function __construct($post) {
//run the parrent constructor
parent::__construct($post);
}
function render() {
ob_start();
?>
<div class="<?php echo $this->get_module_classes();?>">
<div class="td-module-image">
<?php echo $this->get_image('td_324x160');?>
<?php if (td_util::get_option('tds_category_module_1') == 'yes') { echo $this->get_category(); }?>
</div>
<?php echo $this->get_title();?>
<div class="td-module-meta-info">
<?php echo $this->get_author();?>
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
<!-- --><?php //echo $this->get_date():?>
<?php echo $this->get_comments();?>
</div>
<?php echo $this->get_quotes_on_blocks();?>
</div>
<?php return ob_get_clean();
}
}
What am I doing wrong? Thanks again!