MyBB Community Forums
[How To?] Show Most Viewed Threads based on days? - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: [How To?] Show Most Viewed Threads based on days? (/thread-216193.html)



Show Most Viewed Threads based on days? - bekti - 2018-03-05

hai all, I want to show most viewed threads based on 7 days  before today, can anybody help me out?

I create this code

if(!$most_viewed)
{
    $cache->update_most_viewed_threads();
    $most_viewed = $cache->read("most_viewed_threads", true);
}
$x = 0;
if(!empty($most_viewed))
{
    foreach($most_viewed as $key => $thread)
    {
        $x+=1;
        if($x <= 7)  
        {
            $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
            $numberbit = my_number_format($thread['views']);
	   
            $thread['threadlink'] = get_thread_link($thread['tid']);
            eval("\$diskusi_most .= \"".$templates->get("index_most_viewed")."\";");
        }
    }
}
but how to filter it to 7 days before today only?

thanks Big Grin