MyBB Community Forums

Full Version: Show GMT Time
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In the "header_welcomeblock_member" template there is this code:

{$lang->welcome_current_time}

wich shows the current time in the format configured in admin CP (Board Settings->Change->Data and Time formats and change "Time Format")

Well, I would like to show my users also the GMT time so I can give them alerts in GMT time that is not relative to every one's time zone.

Example: in this forum I can see (I'm GMT-5):

Current time: 06-01-2008, 01:19 PM

And I want my users see something like this:

Current time: 06-01-2008, 01:19 PM (18:19 GMT)

Any ideas on how to do this? I did search the forum, but nothing came up. I can understand the codes of the PHP date & time functions, but I don't know where to set them up to do this.

Your help is really appreciated. Big Grin
U mean u wanna make it so that the users can see what is the time in your country and their time
Try this:
Open global.php from your MyBB forum root (via ftp) and open this file with a text editor.
Find:
// Set the current date and time now
$datenow = my_date($mybb->settings['dateformat'], time(), '', false);
$timenow = my_date($mybb->settings['timeformat'], time());
$lang->welcome_current_time = sprintf($lang->welcome_current_time, $datenow.', '.$timenow);

REPLACE with this:
// Set the current date and time now
$datenow = my_date($mybb->settings['dateformat'], time(), '', false);
$timenow = my_date($mybb->settings['timeformat'], time());
$timenowgmt = my_date($mybb->settings['timeformat'], time(), "-");
$lang->welcome_current_time = sprintf($lang->welcome_current_time, $datenow.', '.$timenow. ' ('.$timenowgmt.' GMT)');

Save changes and upload over original global.php file.

In this way you will have: Current time: 06-01-2008, 01:19 PM (18:19 GMT)

If you want to have: Current time: 06-01-2008, 01:19 PM (18:19 GMT-5) - just for registered users, of course... your guests will see Current time: 06-01-2008, 01:19 PM (18:19 GMT)
For this Replace with:
// Set the current date and time now
$datenow = my_date($mybb->settings['dateformat'], time(), '', false);
$timenow = my_date($mybb->settings['timeformat'], time());
$timenowgmt = my_date($mybb->settings['timeformat'], time(), "-");
$lang->welcome_current_time = sprintf($lang->welcome_current_time, $datenow.', '.$timenow. ' ('.$timenowgmt.' GMT'.$mybb->user['timezone'].')');
WHOO-HOO! THANK you SOOO much mybbromania!!

That was exactly was I was looking for ^_^

And @dikidera, well: yes, but the objective is not showing them the time of MY country, but "GMT Time", wich is a guideline to international users Big Grin

Thanks again guys. Really appreaciated the help Big Grin