Jump to content

Specific Board Time
   (0 reviews)

c.widow
  • MyBB has the current time setting, which can have a default enabled though if a user has a time zone selected the time will then update to their time. A lot of boards run big events or other things by a specific timezone/set time for the board. Here I will show you how to insert your own!

    Software: MyBB

Specific Board Time

Tutorial Created By: isoldehn
Tutorial Permissions: Please do not re-post this tutorial else where, instead link someone to this thread.

- Additionally, you are NOT required to credit me if you use this on your board BUT I do wish for you to share this with those that ask about it if they ever do (share the knowledge, be kind).
Tutorial Needs: Overall, the ability to copy and paste.
- FTP Access & Knowledge On Editing Core Files OR PHP In Templates / Complex Templates Plugin

 

Step One

Determine the usage you would prefer. If you are going to edit a core file to insert this script then open global.php, else if you are going to use the PHP In Templates / Complex Templates plugin ensure it is uploaded and activated.

 

Step Two

IF editing a core file follow as directed:

I am going to assume that you would like to show this in the header template, therefor in global.php find:

// Set up some of the default templates
eval('$headerinclude = "'.$templates->get('headerinclude').'";');
eval('$gobutton = "'.$templates->get('gobutton').'";');
eval('$htmldoctype = "'.$templates->get('htmldoctype', 1, 0).'";');
eval('$header = "'.$templates->get('header').'";');

 

Directly above the find previously add:

date_default_timezone_set("PHPTIMEZONEFORMAT");
$boardTime = date("PHPDATEFORMAT");

From here we need to declare time zone and date formatting! We are working with PHP therefore we need to use the proper formats.

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

     

Save the global.php file, return to your site and refresh the page. If the page turns white you have done something wrong. Go back remove the code you added and try again. It is suggested that you ALWAYS use a code editor of sorts to do this, else you may run into errors with formatting.

 

If the board is still there then it should be working. So lets head to our header templates. Admin CP --> Templates & Style --> Templates --> your current template set --> Header Templates --> header and add in where you would like the time to show: 

<b>Board Time:</b> {$boardTime}

Save and check for results.

 

IF using the mentioned plugin follow as directed:

As this is no longer core file specific, we can add this anywhere we please in any template BUT again I am going to assume you would like this in the header template. Admin CP --> Templates & Style --> Templates --> your current template set --> Header Templates --> header and add in where you would like the time to show:

<?php date_default_timezone_set("PHPTIMEZONEFORMAT"); $boardTime = date("PHPDATEFORMAT"); ?>
<b>Board Time:</b> {$boardTime}

From here we need to declare time zone and date formatting! We are working with PHP therefore we need to use the proper formats.

  • EXAMPLE:
    <?php date_default_timezone_set("America/Chicago"); $boardTime = date("m-d-Y, h:i A"); ?>
    <b>Board Time:</b> {$boardTime}

Save and check for results.

 

--------------

 

All finished!





User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

There are no reviews to display.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use, Guidelines and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.