vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Local time and date in post, pm, usernotes and profile v1.5 (https://vborg.vbsupport.ru/showthread.php?t=60863)

Boofo 01-27-2004 10:00 PM

Local time and date in post, pm, usernotes and profile v1.5
 
Local time and date in post, pm, usernotes and profile
Version 1.5
(By Boofo)

This hack will add the local time and date of users in the posts, pms, usernotes and profile. That way you will know what the time and date is where they are located. I use this on my site so I will have an idea if it is the middle of the night, where they are at, or daytime. With your users living in all corners of the globe, this hack is a nice gauge of the different time zones without having to figure out each one in your head. ;)

Thanks goes out to Link14716 for pointing me in the right direction for the pm time and helping to verify the code. And everyone who chipped in at vbulletin.com to help me figure out vB3's new ways of doing things. A special thanks goes out to Chen Avinadav for making the first local time hack for vB2 and allowing me to release it for vB3. ;)

Version Information:
Version 1.0 --Initial release
Version 1.1 --Fixed bug where the User CP DST setting was not being accounted for. Thanks goes out to squall14716 for the fix. ;)
Version 1.2 --Fixed bug where a few people's time was off by an hour or two in the showthread, but right on target everywhere else. Moved the code from the showthread.php into the functions_showthread.php, where it should have been in the first place. Thanks Natch, for all of your hard work in helping me track this down. ;)
Version 1.3 --Fixed bug where local time and date was not showing up in a member's profile when the "Additional Information" box was empty due to them not entering any personal information in their profile. It would only show an N/A.
Version 1.4 --Added ability to have the local time and date to also show up in the showpost.
Version 1.5 --Fixed last known bug where the User CP DST setting was not being automatically accounted for when the DST changed. The Version 1.1 fix seemed to be only temporary and not a total solution. This should take care of it. ;)


Files to edit: 4
functions_showthread.php
private.php
usernote.php
member.php

Templates to edit: 3
postbit
postbit_legacy
memberinfo


If you find this hack useful, please click the install button.

MindTrix 01-28-2004 02:38 PM

Yeah i loved this on vB2, was very handy. Thank you for the conversion!

nhochochack 01-28-2004 02:44 PM

thanks !! good job

Boofo 01-28-2004 03:03 PM

You are both very welcome. ;)

Zelda-King 01-28-2004 03:16 PM

At the moment I've just installed the 'user profile' bits (member.php and the MEMBERINFO template). Those with offset -5 (EST) seem OK but I, being GMT (offset 0) am showing up 2 hours behind and someone with offset -6 is showing as offset -8.

Boofo 01-28-2004 03:41 PM

Quote:

Originally Posted by Zelda-King
At the moment I've just installed the 'user profile' bits (member.php and the MEMBERINFO template). Those with offset -5 (EST) seem OK but I, being GMT (offset 0) am showing up 2 hours behind and someone with offset -6 is showing as offset -8.

What is your server time set to in the Admin CP? And do you have the DST settings right for your server time? Let me know what that is set at and I will test it here on my setup. It is running true to form for me so it might just be a setting off somewhere.

If everything is set right on your end, try this and let me know what happens.

change

PHP Code:

$vboptions['timeoffset'

to

PHP Code:

$vboptions['hourdiff'

in the code

Natch 01-28-2004 04:18 PM

Quote:

Originally Posted by Boofo
What is your server time set to in the Admin CP? And do you have the DST settings right for your server time?

Yup for me, but I'm having an issue as well ... it's working just fine, but it's not taking into account the time offset for DST ...

Boofo 01-28-2004 04:23 PM

Quote:

Originally Posted by Natch
Yup for me, but I'm having an issue as well ... it's working just fine, but it's not taking into account the time offset for DST ...

Do you have your settings in your usercp set to automatically detect DST?

Zelda-King 01-28-2004 04:23 PM

Quote:

Originally Posted by Boofo
What is your server time set to in the Admin CP? And do you have the DST settings right for your server time? Let me know what that is set at and I will test it here on my setup. It is running true to form for me so it might just be a setting off somewhere.

Last I gathered, the admin CP server time was obsolete and not used any more. I can tell you the Default Time Zone Offset is at the default -5 and I have it all set correctly. Everyone's correct time displays. Just the times in the hack don't tally. Watch this space as I try out the code...

Zelda-King 01-28-2004 04:30 PM

Quote:

Originally Posted by Boofo
If everything is set right on your end, try this and let me know what happens.

change

PHP Code:

$vboptions['timeoffset'

to

PHP Code:

$vboptions['hourdiff'

in the code

Where is that code? I've only installed the profile bits and that code is not in member.php or MEMBERINFO.

Boofo 01-28-2004 04:34 PM

It is at the end of these lines (highlighted in yellow):

// Local Date and Time in Profile
$post['localtime'] = date($vboptions['timeformat'], TIMENOW+($post['timezoneoffset']-$vboptions['timeoffset'])*3600);
$post['localdate'] = date($vboptions['dateformat'], TIMENOW+($post['timezoneoffset']-$vboptions['timeoffset'])*3600);
// Local Date and Time in Profile

Zelda-King 01-28-2004 04:48 PM

Quote:

Originally Posted by Boofo
It is at the end of these lines (highlighted in yellow):

// Local Date and Time in Profile
$post['localtime'] = date($vboptions['timeformat'], TIMENOW+($post['timezoneoffset']-$vboptions['timeoffset'])*3600);
$post['localdate'] = date($vboptions['dateformat'], TIMENOW+($post['timezoneoffset']-$vboptions['timeoffset'])*3600);
// Local Date and Time in Profile

Ah, so it is. I can only imagine why my first search didn't work. Anyway, the results to that change are disastrous;

Local Time:
11:49 AM
Local Date:
12-13-2006

(Actual time being 06:49pm)

Boofo 01-28-2004 04:51 PM

Quote:

Originally Posted by Zelda-King
Ah, so it is. I can only imagine why my first search didn't work. Anyway, the results to that change are disastrous;

Local Time:
11:49 AM
Local Date:
12-13-2006

(Actual time being 18:49pm)

Ok, I just wanted to be sure it was that far off. ok, with the hack like it is when you go back to the original code, how far off are we?

Zelda-King 01-28-2004 04:57 PM

With my offset as 0;

Local Time:
04:59 PM
Local Date:
01-28-2004

Actual local time being 06:59pm.

For the record, I have my DST settings set to be automatically detected.

Boofo 01-28-2004 05:10 PM

Quote:

Originally Posted by Zelda-King
With my offset as 0;

Local Time:
04:59 PM
Local Date:
01-28-2004

Actual local time being 06:59pm.

For the record, I have my DST settings set to be automatically detected.

Ok, in your Admin CP, do you have this set to NO?

Enable Daylight Savings (dstonoff)

Zelda-King 01-28-2004 05:16 PM

Yes I did. Enabling it hasn't changed anything though, apparantly. My time is still two hours behind.

Boofo 01-28-2004 05:21 PM

That's really strange, because I have been running it on my forums for 3 weeks now and it has never faltered once. I wanted to thoroughly test it before I released it.

I will look at the code and figure out what is going on. I will post a fix here shortly. Please bear with me. I WILL get this working for you. ;)

Is everyone else having the same problem?

Natch 01-28-2004 06:57 PM

Yup - like I said mine is one hour out for me (and I am in DST)

Boofo 01-28-2004 11:42 PM

Ok. Try this for the code in the member.php and let me know if it fixes it in the profile. If it does, I will change the rest of the code and get it to you.

In member.php, replace:

PHP Code:

// Local Date and Time in Profile
$post['localtime'] = date($vboptions['timeformat'], TIMENOW+($post['timezoneoffset']-$vboptions['timeoffset'])*3600);
$post['localdate'] = date($vboptions['dateformat'], TIMENOW+($post['timezoneoffset']-$vboptions['timeoffset'])*3600);
// Local Date and Time in Profile 

with:

PHP Code:

// Local Date and Time in Profile
    
$post['tzoffset'] = $post['timezoneoffset']; 
    if (
$post['dstonoff']) 
     { 
        
// DST is on, add an hour 
        
$post['tzoffset']++; 
    }
$post['localtime'] = date($vboptions['timeformat'], TIMENOW+($post['tzoffset']-$vboptions['timeoffset'])*3600);
$post['localdate'] = date($vboptions['dateformat'], TIMENOW+($post['tzoffset']-$vboptions['timeoffset'])*3600);
// Local Date and Time in Profile 


Natch 01-29-2004 12:42 AM

You - sir - are a gentleman and a scholar :)

That's done the trick :D :D

Boofo 01-29-2004 01:02 AM

Quote:

Originally Posted by Natch
You - sir - are a gentleman and a scholar :)

That's done the trick :D :D

Ok, if you make those same changes in the other code, it should work like that everywhere the code is. I will update the install file as soon as I hear back from Zelda-King to make sure it fixed it for him also. Thank you everyone for your patience and understanding. I had not run into this problem on my site yet. Glad we found it now. ;)

BTW: The true credit for this fix goes to squall14716. Without his help, I would still be tearing what little hair I have left out. ;)

Natch 01-29-2004 01:15 AM

But with those edit's it's all good :) Great work!

('cept private.php - that's now 1 hr over ...)

Boofo 01-29-2004 01:40 AM

Quote:

Originally Posted by Natch
But with those edit's it's all good :) Great work!

('cept private.php - that's now 1 hr over ...)

In the private.php, you need to replace the code with:

PHP Code:

// Local Date and Time in PM
    
$pm['tzoffset'] = $pm['timezoneoffset'];
    if (
$pm['dstonoff'])
     {
        
// DST is on, add an hour
        
$pm['tzoffset']++;
    }
$pm['localtime'] = date($vboptions['timeformat'], TIMENOW+($pm['tzoffset']-$vboptions['timeoffset'])*3600);
$pm['localdate'] = date($vboptions['dateformat'], TIMENOW+($pm['tzoffset']-$vboptions['timeoffset'])*3600);
// Local Date and Time in PM 

* First post has been updated with all the new code. *

Natch 01-29-2004 01:44 AM

Please excuse my n00bish-ness ...

Thanks for the update :)

Great job - all cool now :)

Boofo 01-29-2004 02:13 AM

Great! And don't worry about being a newbie. We have all been there and some of us still go there from time to time. ;)

Glad it's working for you, now. ;)

EvilLS1 01-29-2004 02:20 AM

Nice one Boofo! :)

Boofo 01-29-2004 02:31 AM

Thank you, my friend. ;)

Natch 01-29-2004 03:32 AM

Quote:

Originally Posted by Boofo
Great! And don't worry about being a newbie. We have all been there and some of us still go there from time to time. ;)

Glad it's working for you, now. ;)

Boofo: sorry to pop back up again, but in Hybrid and Threaded modes, for some reason the template edit is there, but the values of $post[localdate] and $post[localtime] are empty ...

Boofo 01-29-2004 03:50 AM

Quote:

Originally Posted by Natch
Boofo: sorry to pop back up again, but in Hybrid and Threaded modes, for some reason the template edit is there, but the values of $post[localdate] and $post[localtime] are empty ...

You got me there. I don't use anything but linear mode. I would say do a condition checking for those modes and only allow it in linear. Otherwise, I will take a look at it and see if I can figure something out for it. ;)

Boofo 01-29-2004 05:17 AM

Natch, I think I may have your solution. In the showthread.php:

Find:

PHP Code:

  $post $postarray["$id"]; 

AFTER it add:

PHP Code:

// Local Date and Time in Post
    
$post['tzoffset'] = $post['timezoneoffset'];
    if (
$post['dstonoff'])
     {
        
// DST is on, add an hour
        
$post['tzoffset']++;
    }
  
$post['localtime'] = date($vboptions['timeformat'], TIMENOW+($post['tzoffset']-$vboptions['timeoffset'])*3600);
  
$post['localdate'] = date($vboptions['dateformat'], TIMENOW+($post['tzoffset']-$vboptions['timeoffset'])*3600);
// Local Date and Time in Post 

and let me know if that fixes it for both of them.

Natch 01-29-2004 05:30 AM

It's fixed it up, but it's out of sync again (1 hour behind) ...

Boofo 01-29-2004 05:35 AM

Are you sure? It shows the same time for all 3 on my site. That shouldn't have changed anything for the DST. Try moving the code below this line then:


PHP Code:

 $parsed_postcache = array('text' => '''images' => 1); 


Natch 01-29-2004 05:52 AM

Should I have two copies of this code ? or just one ?

Boofo 01-29-2004 06:09 AM

Quote:

Originally Posted by Natch
Should I have two copies of this code ? or just one ?

There should be 2 copies in the showthread.php. The original one way up top of the file (from the first fix for the DST) and the new one I just had you add.

Natch 01-29-2004 06:45 AM

OK - moved that code down ...

EDIT: still one hour too early.

Boofo 01-29-2004 06:52 AM

How does it show in linear mode? It was working fine there before, right? Is it still working ok there?

Zelda-King 01-29-2004 02:56 PM

The fix has made it 3 hours (as opposed to the original 2) behind for me and EST has gone back 2 hours.

Boofo 01-29-2004 10:12 PM

Quote:

Originally Posted by Zelda-King
The fix has made it 3 hours (as opposed to the original 2) behind for me and EST has gone back 2 hours.

I'm all out of ideas on this one. It seems to work almost everywhere else without problems. I would say there must be some other issue causing this. But, for the life of me, I can't figure out what it is. I will continue to look at the code and see what might be casuing your time problem and see if there is anything I can do. The only thing that comes to mind right now is that your server time in the Admin CP must be off for some reason. This hack relies on that setting being right.

Natch 01-29-2004 10:24 PM

OT: Do I have to monitor/change the server time for DST as well ?

Link14716 01-29-2004 11:58 PM

Quote:

Originally Posted by Natch
OT: Do I have to monitor/change the server time for DST as well ?

No, I don't believe so.


All times are GMT. The time now is 01:56 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01952 seconds
  • Memory Usage 1,862KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (10)bbcode_php_printable
  • (15)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete