MyBB Community Forums

Full Version: Days Online
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to display forum up online days in the footer... for example if my forum has been up online running for a year then in the footer I'd like it to say 365 Days Online.

I've seen it done before in some forums not sure if it's a plugin or can it be done with php?

Thank you.
It is a plugin Livewire coded by Neo
https://community.mybb.com/mods.php?action=view&pid=937
I added something simulair in the section 'Board statistics' on te bottom of the index page:

'This forum is online for xxx days (started on xx-xx-xxxx)'

I did this by editing the 'index_stats' template to the following:

<tr><td class="tcat"><span class="smalltext"><strong>{$lang->boardstats}</strong></span></td></tr>
<tr>
<td class="trow1"><span class="smalltext">
{$lang->stats_posts_threads}<br />
{$lang->stats_numusers}<br />
{$lang->stats_newestuser}<br />
{$lang->stats_mostonline}<br />
This forum is online for <script type="text/javascript"> var eventdate = new Date("May 13, 2009 00:00:00 GMT");d=new Date();count=Math.floor((d.getTime()- eventdate.getTime())/1000);count=Math.floor(count/(60*60*24));document.write(count);</script> days (started on may 13th 2009).<br />
</span>
</td>
</tr>

Maybe you can do it likewise? You just have to adjust your own dates.......
Fairly, your site start date is the registration date of your UID 1. So you can use that.
Add these 3 lines at the end of your global.php

$query = $db->simple_select('users', 'regdate', 'uid=1', array('limit' => 1));
$sitestart = $db->fetch_array($query);
$siteup = nice_time(TIME_NOW - $sitestart['regdate']);

Now you can use {$siteup} anywhere in your templates which will produce something like 3 Weeks, 3 Days, 11 Hours
Hard code or play with language files to prepend texts like "Site uptime:"
(2018-05-10, 08:58 AM)effone Wrote: [ -> ]Fairly, your site start date is the registration date of your UID 1. So you can use that.
Add these 3 lines at the end of your global.php

$query = $db->simple_select('users', 'regdate', 'uid=1', array('limit' => 1));
$sitestart = $db->fetch_array($query);
$siteup = nice_time(TIME_NOW - $sitestart['regdate']);

Now you can use {$siteup} anywhere in your templates which will produce something like 3 Weeks, 3 Days, 11 Hours
Hard code or play with language files to prepend texts like "Site uptime:"

I guess that's what I was looking for and it worked thank you, but how can I remove weeks/days/hours? Instead I want it to say Days for example 300 days... 600 days.. 1000 and so on.
Try this:

$query = $db->simple_select('users', 'regdate', 'uid=1', array('limit' => 1));
$sitestart = $db->fetch_array($query);
$siteup = "Site online: <strong>".floor((TIME_NOW - $sitestart['regdate'])/86400)." days</strong>";

You may also like to cache the data to save a query in every page load.
(2018-05-11, 06:16 AM)effone Wrote: [ -> ]Try this:

$query = $db->simple_select('users', 'regdate', 'uid=1', array('limit' => 1));
$sitestart = $db->fetch_array($query);
$siteup = "Site online: <strong>".floor((TIME_NOW - $sitestart['regdate'])/86400)." days</strong>";

You may also like to cache the data to save a query in every page load.

Thanks pal. Smile