PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
brentnhunter
Client


Joined: Sep 10, 2004
Posts: 166

PostPosted: Mon Oct 18, 2004 11:34 pm Reply with quote Back to top

I would like the time on my nuke website to be my local time, not the time of the server. Anyone know how I can change it?

Thank you for your help.

Brent Hunter
Only registered users can see links on this board!
Get registered or login to the forums!
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 19, 2004 5:09 am Reply with quote Back to top

The forums are easy - use forum admin but people can adjust it as they wish. If you are talking about the news items, many have tried - many have died Laughing.

You can try this little diddy
Only registered users can see links on this board!
Get registered or login to the forums!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
brentnhunter
Client


Joined: Sep 10, 2004
Posts: 166

PostPosted: Tue Oct 19, 2004 7:56 am Reply with quote Back to top

OK thanks Sad
View user's profile Send private message
Holbrookau
Hangin' Around


Joined: Jun 25, 2004
Posts: 32

PostPosted: Tue Oct 19, 2004 9:01 pm Reply with quote Back to top

The following is an adaption of what we use at IPBNuke.net (InvisionPowerBoard rather then phpBB). It is by no means a finished solution but could be a basis to work with.
When a user is logged in, their timezone offset from the phpBB forums is applied to post times in news articles and comments (and anywhere else the formatTimstamp funtion is called upon). If not logged in, the times shown will be in GMT.

In mainfile.php -
Find:
Code:
function formatTimestamp($time) {
    global $datetime, $locale;
    setlocale (LC_TIME, $locale);
    ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
    $datetime = strftime(""._DATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
    $datetime = ucfirst($datetime);
    return($datetime);
}

Replace with:
Code:
function formatTimestamp($time) {
    global $db, $prefix, $datetime, $user, $cookie;
   $convtime = strtotime($time);
   if (is_user($user)) {
      $result = $db->sql_query("SELECT user_timezone FROM ".$prefix."_users WHERE user_id='$cookie[0]'");
      $row = $db->sql_fetchrow($result);
      $timeoffset = intval($row['user_timezone']*3600);
   $datetime = gmdate(""._DATESTRING3."", $convtime + $timeoffset);
   } else {
   $datetime = gmdate(""._DATESTRING4."", $convtime);
   }
    return($datetime);
}


In language/lang-XXXX.php (where XXXX is your language) -
Find:
Code:
define("_BANTHIS","Ban This IP");
(or whatever the last define line is in your file)

Add After:
Code:
define("_DATESTRING3","l, jS F @ g:i a");
define("_DATESTRING4","l, jS F @ g:i a \G\M\T");


Save both and upload.
View user's profile Send private message
brentnhunter
Client


Joined: Sep 10, 2004
Posts: 166

PostPosted: Tue Oct 19, 2004 11:33 pm Reply with quote Back to top

Thanks, this would be great if it works (I don't use InvisionPowerBoard, I use phpbb) but I'll give it a try.

But first I can't figure out how to change the system timezone. When I go to Admin CP, Forums, then Configuration under the General Admin area, there is an option in there that is titled "System Timezone". No matter what I put in there, when I make a post, it shows the time as being 1 hour earlier than what it is in my local area. I'm not sure why it won't work for me, but is that the timezone you are talking about?
View user's profile Send private message
Holbrookau
Hangin' Around


Joined: Jun 25, 2004
Posts: 32

PostPosted: Wed Oct 20, 2004 12:20 am Reply with quote Back to top

Its an adaption of what we use with IPB - I rewrote it to work for phpBB..
The System Timezone should be set so that the board is in GMT time. Then, each member can enter their true Timezone in their Profile and have posts show in local time.
This is the way all boards should be setup.
View user's profile Send private message
brentnhunter
Client


Joined: Sep 10, 2004
Posts: 166

PostPosted: Wed Oct 20, 2004 4:34 am Reply with quote Back to top

Agreed... and where do I set the System Timezone? In the server itself (in which case, Raven would change) or somewhere in my own nuke or phpbb setup? What about the question I asked above about the place I was trying to change?

Brent
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Oct 20, 2004 6:08 am Reply with quote Back to top

There isn't a single setting in nuke to do this,; that's the problem. What Holbrook is saying, if I understand him correctly, is that he is offering a means to take the timezone setting from the forums (which people can change) and adapt an offset to any nuke code that calls 'formatTimestamp'. That way everyone sees the times in THEIR timezone, just as we do in the forums. Holbrook, correct me if I'm wrong.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Wed Oct 20, 2004 6:38 am Reply with quote Back to top

This is nice! I'm still and hour off for some reason but one heck of a lot nicer then it was. I set Forums Sytem Time to GMT and my preference to -6 but the time in comments shows and hour earlier 6:30 instead of 7:30.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Oct 20, 2004 6:48 am Reply with quote Back to top

Aren't you on CDT? If so, you should be -5 shouldn't you?
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Wed Oct 20, 2004 7:03 am Reply with quote Back to top

Your right Grr!
View user's profile Send private message
Holbrookau
Hangin' Around


Joined: Jun 25, 2004
Posts: 32

PostPosted: Wed Oct 20, 2004 7:18 am Reply with quote Back to top

Quote:
where do I set the System Timezone?
I assumed here: "When I go to Admin CP, Forums, then Configuration under the General Admin area, there is an option in there that is titled "System Timezone"." If that isn't the right place perhaps one of the other guys can point you in the right direction - it's has been a while since I played with phpBB.
Quote:
correct me if I'm wrong
No correction required. Wink
View user's profile Send private message
brentnhunter
Client


Joined: Sep 10, 2004
Posts: 166

PostPosted: Wed Oct 20, 2004 8:21 am Reply with quote Back to top

Hi Raven, yes I understood what what being proposed, the problem is that if my time isn;t set correctly in the first place, then it won't do much good to put in a code snippet to make a correction to offset it it to get my correct local time. And even now I'm still trying to find out why I can't change the time zone in the forums. Maybe I'll describe the problem again, pasted from my earlier post:

But first I can't figure out how to change the system timezone. When I go to Admin CP, Forums, then Configuration under the General Admin area, there is an option in there that is titled "System Timezone". No matter what I put in there, when I make a post, it shows the time as being 1 hour earlier than what it is in my local area. I'm not sure why it won't work for me <snip>

Thanks for any help anyone can provide!

Brent
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Oct 20, 2004 8:45 am Reply with quote Back to top

That's not where you make your changes Laughing - You have to make it in your Profile Timezone, not the System Timezone.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
brentnhunter
Client


Joined: Sep 10, 2004
Posts: 166

PostPosted: Wed Oct 20, 2004 8:58 am Reply with quote Back to top

Ah! That worked! Thank you.

I'll check out the script mods sometime soon.

In the meantime, the other time the time zone difference bothers me is when I go to my website and look at the User Info stats, like how many members signed up that day, yesterday, etc. Will the above script mod fix that problem too?

Thanks again!

Brent
View user's profile Send private message
Holbrookau
Hangin' Around


Joined: Jun 25, 2004
Posts: 32

PostPosted: Wed Oct 20, 2004 9:19 am Reply with quote Back to top

Quote:
Will the above script mod fix that problem too
Unless the block code is rewritten to use the formatTimstamp function, then no it won't.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Oct 20, 2004 10:04 am Reply with quote Back to top

I have published that fix somewhere in the forums. See if you can find it - if not I'll look later.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Sun Jan 09, 2005 2:26 pm Reply with quote Back to top

Holbrookau wrote:
The following is an adaption of what we use at IPBNuke.net (InvisionPowerBoard rather then phpBB). It is by no means a finished solution but could be a basis to work with.
When a user is logged in, their timezone offset from the phpBB forums is applied to post times in news articles and comments (and anywhere else the formatTimstamp funtion is called upon). If not logged in, the times shown will be in GMT.

In mainfile.php -
Find:
Code:
function formatTimestamp($time) {
    global $datetime, $locale;
    setlocale (LC_TIME, $locale);
    ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
    $datetime = strftime(""._DATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
    $datetime = ucfirst($datetime);
    return($datetime);
}

Replace with:
Code:
function formatTimestamp($time) {
    global $db, $prefix, $datetime, $user, $cookie;
   $convtime = strtotime($time);
   if (is_user($user)) {
      $result = $db->sql_query("SELECT user_timezone FROM ".$prefix."_users WHERE user_id='$cookie[0]'");
      $row = $db->sql_fetchrow($result);
      $timeoffset = intval($row['user_timezone']*3600);
   $datetime = gmdate(""._DATESTRING3."", $convtime + $timeoffset);
   } else {
   $datetime = gmdate(""._DATESTRING4."", $convtime);
   }
    return($datetime);
}


In language/lang-XXXX.php (where XXXX is your language) -
Find:
Code:
define("_BANTHIS","Ban This IP");
(or whatever the last define line is in your file)

Add After:
Code:
define("_DATESTRING3","l, jS F @ g:i a");
define("_DATESTRING4","l, jS F @ g:i a \G\M\T");


Save both and upload.


Just wanted to bump this because it is so cool and got so lost I could hardly find it.
View user's profile Send private message
Muffin
Client


Joined: Apr 10, 2004
Posts: 649
Location: UK

PostPosted: Sun Jan 09, 2005 6:17 pm Reply with quote Back to top

So if a sites in the UK and the server is in the US that wouldnt make any difference, the news articles and stuff would be the same as the user's profile time right?

hey this is really good, I've wanted to get this sorted for ages. Solves the problem of daylight saving time changes too.

Thanks a lot!!!

One question, when a news article is posted with the date you post it, how does this mod affect that, and old articles????
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Sun Jan 09, 2005 8:57 pm Reply with quote Back to top

It doesn't effect that at all just how the time is displayed to the user.
View user's profile Send private message
Muffin
Client


Joined: Apr 10, 2004
Posts: 649
Location: UK

PostPosted: Mon Jan 10, 2005 7:01 am Reply with quote Back to top

Thanks Six, thought that was the case.
View user's profile Send private message
Holbrookau
Hangin' Around


Joined: Jun 25, 2004
Posts: 32

PostPosted: Mon Jan 17, 2005 2:31 am Reply with quote Back to top

I've just updated our IPBNuke version of this code to use the Locale Time Format setting in Administration->Preferances, and thought I should do the same for the phpBB code posted here.
In mainfile.php -
Find:
Code:
function formatTimestamp($time) {
    global $datetime, $locale;
    setlocale (LC_TIME, $locale);
    ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
    $datetime = strftime(""._DATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
    $datetime = ucfirst($datetime);
    return($datetime);
}
Replace it with:
Code:
function formatTimestamp($time) {
    global $db, $prefix, $datetime, $user, $cookie, $locale;
    setlocale (LC_TIME, $locale);
   $convtime = strtotime($time);
   if (is_user($user)) {
      $result = $db->sql_query("SELECT user_timezone FROM ".$prefix."_users WHERE user_id='$cookie[0]'");
      $row = $db->sql_fetchrow($result);
      $timeoffset = intval($row['user_timezone']*3600);
      $datetime = gmstrftime(""._DATESTRING3."", $convtime + $timeoffset);
      } else {
      $datetime = gmstrftime(""._DATESTRING4."", $convtime);
      }
    return($datetime);
}

In language/lang-XXXX.php (where XXXX is your language) -
Find:
Code:
define("_BANTHIS","Ban This IP");
(or whatever the last define line is in your file).
Add After:
Code:
define("_DATESTRING3","%A, %B %e, %Y @ %I:%M %p");
define("_DATESTRING4","%A, %B %e, %Y @ %I:%M %p %Z");
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon Jan 17, 2005 5:03 am Reply with quote Back to top

I have made this a Sticky Smile - Thanks!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Holbrookau
Hangin' Around


Joined: Jun 25, 2004
Posts: 32

PostPosted: Mon Jan 17, 2005 7:57 am Reply with quote Back to top

Cool - never been a sticky before! Dance-Y

Some info regarding locale settings..
The default PHP-Nuke setting for Locale Time Format is en_US (English languge/United States location). If, for example, you wanted the date/time displayed in Spanish you would probably use es_ES, French would be fr_FR, etc.
However, some server operating systems don't use the exact same format - FreeBSD for example requires a longer string, eg: en_US.ISO8859-1. So if changing your Locale setting makes no differance to the timestamps shown, you should probably contact your host for advice on the correct format.
But wait, there's more!
If you wish to use a Locale string of more than 10 characters you will need to modify your PHP-Nuke database. The locale field in the nuke_config table has a limit of 10 characters - this needs to be increased to at least the same length as your Locale string. The longest string for FreeBSD is 16 characters, so that is what I've used.
The backend_language field in the same table also has a default limit of 10 characters and should be increased as well.
Hope this helps.
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum