Log in

View Full Version : Why doesn't this code work for 3.5?


Boofo
08-18-2005, 11:28 PM
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?

// 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'], 0, 1) != '-')
{
// 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, 11:48 PM
$this->post
Should be:
$userinfo
Right? Since you're sticking it in member.php, well thats for the user your viewing, your own user acc would be:
$vbulletin->userinfo

- Zero Tolerance

Boofo
08-19-2005, 12:00 AM
How would I do it for my account and the user viewing at the same time then? Or did I misunderstand something?

Boofo
08-19-2005, 12:08 AM
Still doesn't work. I used this code and it doesn't show the local time or date in the profile.

// 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'], 0, 1) != '-')
{
// 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, 08: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, 09:06 PM
Try this.

Hook: member_complete

// 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'], 0, 1) != '-')
{
// 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-20-2005, 12:32 AM
That worked, sir. Thank you. ;)

Is this where I messed up then?

Should be:

$vbulletin->options

where I had:

$this->registry->options

Boofo
08-20-2005, 09: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.

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'], 0, 1) != '-')
{
// 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);