vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Why doesn't this code work for 3.5? (https://vborg.vbsupport.ru/showthread.php?t=94596)

Boofo 08-18-2005 10:28 PM

Why doesn't this code work for 3.5?
 
I am converting my local time in postbit and profile hack to vB3.5. The following code (with vB3.5 changes) worked fine in the member.php on vB3.0, but now it doesn't seem to want to work in 3.5 with the member_complete hook. Can someone please tell me why and what I need to change to get it to work now?

PHP Code:

 // Local Date and Time in Post
 
global $vbulletin;
 
$this->post['tzoffset'] = $this->post['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$this->post['tzoffset']++;
  if (
substr($this->post['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$this->post['tzoffset'] = '+' $this->post['tzoffset'];
  }
 }
 
$this->post['localtime'] = date($this->registry->options['timeformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600);
 
$this->post['localdate'] = date($this->registry->options['dateformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600);
// Local Date and Time in Post 


Zero Tolerance 08-18-2005 10:48 PM

PHP Code:

$this->post 

Should be:
PHP Code:

$userinfo 

Right? Since you're sticking it in member.php, well thats for the user your viewing, your own user acc would be:
PHP Code:

$vbulletin->userinfo 

- Zero Tolerance

Boofo 08-18-2005 11:00 PM

How would I do it for my account and the user viewing at the same time then? Or did I misunderstand something?

Boofo 08-18-2005 11:08 PM

Still doesn't work. I used this code and it doesn't show the local time or date in the profile.

PHP Code:

 // Local Date and Time in Profile
 
global $vbulletin;
 
$userinfo['tzoffset'] = $userinfo['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$userinfo['tzoffset']++;
  if (
substr($userinfo['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$userinfo['tzoffset'] = '+' $userinfo['tzoffset'];
  }
 }
  
$userinfo['localtime'] = date($this->registry->options['timeformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
  
$userinfo['localdate'] = date($this->registry->options['dateformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
// Local Date and Time in Profile 


Marco van Herwaarden 08-19-2005 07:44 PM

Guess you would have to retrieve the timezones for the members posting in that thread first. Don't think it is stored with the post.

Andreas 08-19-2005 08:06 PM

Try this.

Hook: member_complete
PHP Code:

// Local Date and Time in Profile
 
$userinfo['tzoffset'] = $userinfo['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$userinfo['tzoffset']++;
  if (
substr($userinfo['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$userinfo['tzoffset'] = '+' $userinfo['tzoffset'];
  }
 }
  
$userinfo['localtime'] = date($vbulletin->options['timeformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
  
$userinfo['localdate'] = date($vbulletin->options['dateformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
// Local Date and Time in Profile 


Boofo 08-19-2005 11:32 PM

That worked, sir. Thank you. ;)

Is this where I messed up then?

Should be:

Quote:

$vbulletin->options
where I had:

Quote:

$this->registry->options

Boofo 08-20-2005 08:25 PM

Kirby, this code seems to work in the postbit, but is it 3.5 ready and the way it should be for the postbit?

I'm using the postbit_display_complete hook for this one.

PHP Code:

  global $vbulletin;
 
$this->post['tzoffset'] = $this->post['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$this->post['tzoffset']++;
  if (
substr($this->post['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$this->post['tzoffset'] = '+' $this->post['tzoffset'];
  }
 }
 
$this->post['localtime'] = date($this->registry->options['timeformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600);
 
$this->post['localdate'] = date($this->registry->options['dateformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600); 



All times are GMT. The time now is 01:42 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.01555 seconds
  • Memory Usage 1,771KB
  • 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
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete