MyBB Community Forums
Own Time/Current Time (Script) - Printable Version

+- MyBB Community Forums (
+-- Forum: 1.8 Support (
+--- Forum: General Support (
+--- Thread: Own Time/Current Time (Script) (/thread-215685.html)

Own Time/Current Time (Script) - isoldehn - 01-31-2018

Users can set their own time preference in their User CP settings. While that is fine there are certain functions of our forum that runs of the forums specific time set.

So what I'm trying to do is create a little variable which will display the forums time so that users can compare it to their own time.

So far I've done a little test page like so:
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'test.php');
$templatelist = "a_test_time";
require "./global.php";
add_breadcrumb("Post Totals Testing", "test.php");

$CaelesteTime = date("m-d-Y, h:i A");

eval("\$a_test_time = \"".$templates->get("a_test_time")."\";");

Works absolutely wonderful on that page. HOWEVER when I go to add this tid bit into the global.php file as this will be added to the footer next to their time (current time selected via User CP) it does not show. I've added it right before the end of the globabl file.
$CaelesteTime = date("m-d-Y, h:i A");

// Run hooks for end of global.php

Any ideas as to why it's not working.

RE: Own Time/Current Time (Script) - dragonexpert - 01-31-2018

I believe the footer template is already evaluated before your code. I don't know the line number off hand, but you could just do a plugin and put something like <default_time> in the footer template and then hook to preoutput_page.

$plugins->add_hook("preoutput_page", "my_function");

function my_function()
global $footer;
$CaelesteTime = date("m-d-Y, h:i A");
$footer = str_replace("<default_time>", $CaelesteTime, $footer);

RE: Own Time/Current Time (Script) - isoldehn - 02-01-2018

I ended up find where the footer begins to eval.

I added the code above that and it worked wonderfully. Thanks for the tip!