miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Specific miniBB Support Forums / Specific /  
 

Time Zone Offset

 
Author x_Maerlyn_x
Guest
#1 | Posted: 18 Jun 2002 08:23 
Adding a timezone offset and timezone descriptor to the setup_options would be nice. This way people could shift the default server time to whatever timezone they wanted or at least display the current timezone being used.

Author Team
8-)
#2 | Posted: 18 Jun 2002 10:08 
x_Maerlyn_x
This is very special feature. If you need it, you can just write at the bottom of forums, which time is on your server (because only this takes place). For example, we are using GMT +3.

Author Anonymous
Guest
#3 | Posted: 3 Jul 2002 22:54 
It might be a better idea to have the timezone offset configurable on a per user basis too so that multi-national forums can have the posts in their local time.

Author x_Maerlyn_x
Partaker
#4 | Posted: 3 Nov 2002 02:40 
Well, I spent some time today to fix this issue. The server I am on is way off time now (see GMT +10). So I did a little modding of the code to accommodate this feature and wanted to pass it on if others are interested...

(Be advised that this code was altered in version 1.2 and I haven't tested it in 1.3 or 1.4)

Add the following lines to the setup_options.php file (I dropped them in right below "$dateFormat='MM DD, YYYY<br>T';"):

---------CLIP---------

//--------------->
/* New vars for time off setting and formatting */

$useTimeDescriptor=TRUE; // If set to TRUE it will display the $timeDescriptor at the end of the time.
$timeDescriptor='GMT'; // Time Zone descriptor (i.e. GMT, EST, PST...)

$useNewDateFormat=TRUE; // If set to TRUE it will use the $newDateFormat for formatting and will disregard the Lang files.
$newDateFormat="M d, Y <br>H:i:s"; // See php docs for format values - date() function, 'string format' parameter

$useOffsetTime=TRUE; // If set to TRUE it will offset the time (and date) by setting the folloing variables.
$offsetTimeDays = 0; // Can be a positive or negative integer
$offsetTimeHours = -10; // Can be a positive or negative integer
$offsetTimeMins = 0; // Can be a positive or negative integer

/* End new vars */
//--------------->

---------END----------

You will also have to alter your bb_functions.php to reflect the following changes in the "convert_date" function (do a search for the function signature):

---------CLIP---------

//--------------->
function convert_date ($dateR) {
global $useOffsetTime, $useNewDateFormat, $useTimeDescriptor;
if ($useOffsetTime) {
global $offsetTimeDays, $offsetTimeHours, $offsetTimeMins;
$dateInt = strtotime($dateR);
$offsetTime = ($offsetTimeDays*86400)+($offsetTimeHours*3600)+($offsetTimeMins*60);

$dateInt += $offsetTime;
$dateR = date("Y-m-d H:i:s", $dateInt);
}
if ($useNewDateFormat) {
global $newDateFormat;
$dateR = date($newDateFormat, strtotime($dateR));
} else {
global $l_months, $dateFormat;
$months = explode (':', $l_months);
if (sizeof($months)!=12) {
$dateR = 'N/A';
} else {
list ($currentD, $currentT) = explode (' ', $dateR);
$cAll = explode ('-', $currentD);
if(substr($cAll[2],0,1)=='0')
$cAll[2]=substr($cAll[2],1,strlen($cAll[2])-1);
$dateR = str_replace ('DD', $cAll[2], $dateFormat);
$dateR = str_replace ('YYYY', $cAll[0], $dateR);
$whichMonth = $cAll[1]-1;
$dateR = str_replace ('MM', $months[$whichMonth], $dateR);

if (substr_count($dateR,'US')>0) {
if ($currentT>='12:00:00' and $currentT<='23:59:59') {
$times=explode(':',$currentT);
$times[0]=$times[0]-12;
if ($times[0]<10)
$times[0]='0'.$times[0];
$currentT=implode(':',$times); $m='pm';
} else {
$m='am';
}
}
$dateR = str_replace ('US', $m, $dateR);
}
$dateR = str_replace ('T', $currentT, $dateR);
}
if ($useTimeDescriptor) {
global $timeDescriptor;
$dateR .= ' ' . $timeDescriptor;
}
return $dateR;
}

//--------------->

---------END----------


Enjoy...

Perhaps the miniBB developers will add this in for their next release (hint, hint).

:)

Author x_Maerlyn_x
Partaker
#5 | Posted: 3 Nov 2002 10:46 
Minor bug...

I forgot to escape the 'r' in the <br /> tag in the string value for $newDateFormat.

I also wrapped the value in single quotes to reflect the standard miniBB conventions.

Update the code to reflect the following line for the fix:

$newDateFormat='M d, Y <b\r />H:i:s';

Author 4days
Champi0n
#6 | Posted: 3 Nov 2002 13:59 
nice one :)

this looks a lot more involved than the version i posted - will have to have a look at it when i get home.

Author Team
8-)
#7 | Posted: 4 Nov 2002 10:57 
x_Maerlyn_x
Well, thanx for your solution :) We need to think more about it - as you see, you get a lot of not so very simple and fast code. But definitely, we'll think about it.

Author x_Maerlyn_x
Partaker
#8 | Posted: 4 Jan 2003 09:07 
Minor update -

Please change the following line (again):

$newDateFormat='M d, Y <b\r>H:i:s';

That fixes a line break issue on some pages. The <br> tag is actually removed on some pages and wasn't getting removed before due to use of the XHTML tag formatting (i.e. <br /> instead of <br>).

This hack works in version 1.5 (and I would assume version 1.3 & 1.4 as it works in 1.2).

Additionally, I only added 17 lines of code to the bb_functions.php file by only wrapping existing code with mine. And I also added 8 new variables to the setup_options.php file (i.e. not very significant). You could actually remove the miniBB $dateFormat variable, my $useNewDateFormat variable and alter the function to only use the new formatting (i.e. remove the conditionals). That would actually result in less code that the original routine.

Specific miniBB Support Forums / Specific /
 Time Zone Offset
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑