MyBB Community Forums

Full Version: Own Time/Current Time (Script)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
<?php
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'test.php');
$templatelist = "a_test_time";
require "./global.php";
add_breadcrumb("Post Totals Testing", "test.php");

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

eval("\$a_test_time = \"".$templates->get("a_test_time")."\";");
output_page($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.
date_default_timezone_set("America/Chicago");
$CaelesteTime = date("m-d-Y, h:i A");

// Run hooks for end of global.php
$plugins->run_hooks('global_end');

Any ideas as to why it's not working.
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;
date_default_timezone_set("America/Chicago");
$CaelesteTime = date("m-d-Y, h:i A");
$footer = str_replace("<default_time>", $CaelesteTime, $footer);
}
I ended up find where the footer begins to eval.

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