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!