View Full Version : Time display at footer of Vbulletin
Doctor Death
04-16-2008, 02:50 PM
How do I display time in a specific timezone at the bottom of vbulletin footer?
My site shows GMT which I would rather have indicate EST but for the life of me I cannot find that option.THanks much!
I am on 3.6.9
Doc
www.ddsog.com/forums
nighthalk
04-16-2008, 03:08 PM
admincp -> vbulletin options -> date and time settings ?
Doctor Death
04-16-2008, 04:00 PM
I have it set in there to EST but my footer continues to show GMT.
www.ddsog.com/forums
nighthalk
04-16-2008, 04:33 PM
What do you have it set to in your usercp
profile settings?
Marco van Herwaarden
04-17-2008, 10:38 AM
If logged in, it will show the users timezone as set in their UserCP.
Solo Drakban
04-24-2008, 01:24 PM
As a followup, what's the correct method in vB for converting a timestamp to the users timezone as specified in the UserCP? I have a series of unix timestamps stored in the EST5EDT timezone and I wish to have a formatted date displayed to the users in their local preference. vbdate() seemed the most logical but it doesn't seem to be doing conversions.
Boofo
04-24-2008, 01:56 PM
Are you trying to get it to show the user's local date and time?
Solo Drakban
04-24-2008, 02:33 PM
Are you trying to get it to show the user's local date and time?
No, I have a Unix timestamp in EDT, I'd like it to display it human-readable in whatever timezone the user has defined in their preferences. So if the timestamp is actually today at 5pm if the user had PST/PDT selected in their preferences they'd see it as 2pm.
I thought vbdate() took care of conversion but this was a mistaken assumption and I was wondering if there was some built-in method of doing this in vB?
Boofo
04-24-2008, 03:22 PM
I think you need to look at the vbmktime function.
Solo Drakban
04-24-2008, 04:17 PM
I think you need to look at the vbmktime function.
That would be if I wanted to convert the human readable into unix epoch.
Basically I have: 1209057260 (which is 2008-04-24 13:14:19, the local timezone of the server). If a user has their preferences set for PST I want to be able to display '2008-04-25 10:14:19' to that user or in whatever TZ they have set from the UserCP.
Boofo
04-24-2008, 04:29 PM
Add the following to the global_start hook:
// Generate Current Date
// get the timestamp for the beginning of today, according to vbulletin->userinfo's timezone
require_once(DIR . '/includes/functions_misc.php');
$timestamp = vbmktime(0, 0, 0, vbdate('m', TIMENOW, false, false), vbdate('d', TIMENOW, false, false), vbdate('Y', TIMENOW, false, false));
$homedate = vbdate('l, F jS, Y', $timestamp);
and then use $homedate wherever you want in the footer.
Solo Drakban
04-24-2008, 06:30 PM
Not exactly what I was looking to do but you've given me enough of a base that I was able to complete the rest of it myself. Thank you very much for the example code, it was greatly appreciated and very helpful! :)
Boofo
04-24-2008, 06:48 PM
I would be curious to see what it helped you come up with. ;)
Solo Drakban
04-24-2008, 07:23 PM
Unfortunately our forums are private or I'd link it, but I've hacked the events display up to appear at the top of the forum home as well as the forum display. I had to do amassive rework of the forumhome_event template and added 2 plugins, one hooking into forumhome_event to modify the data available to the template and one hooking into forumdisplay_start to make event data available there. This basically allowed me to make each event it's own table row and I'm doing conditional formatting based on custom fields from the event (like a priority field that changes the color/bolding/size of the displayed event, etc).
On top of this I've added JavaScript to do a 'count down' to the event start in the event display area. This all worked fine but the game we play is based in the GMT timezone and a lot of members have their user preferences set to this timezone instead of their local time zone. JavaScript however reads the local time from the browser so there was skewing going on with the timer. To fix this I needed to be able to convert time() into whatever timezone the user had selected in their UserCP and provide this to the JavaScript so that 'EventStart' and 'CurrentTime' values were in the same timezone.
There are also some other parts involved with the times, mostly from an external application that's populating timestamps into a table for different 'sub-events' that I needed to convert to whatever timezone the user has selected as well so that all of the times displayed to the user in human readable form were in the same timezone and everything worked. :)
Thanks to your suggestion of vbmktime() I can now close the final bug on this implementation. I would release this mod back to the community but for two things a) I have no idea how to create an importable product and b) It really is an ugly hack. :)
Boofo
04-24-2008, 07:55 PM
PM me if you want to make a product out of this and I will help you set it up and clean up the code. ;)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.