vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help Adding Server Time to Footer (https://vborg.vbsupport.ru/showthread.php?t=266599)

vantastic 07-10-2011 11:27 PM

Help Adding Server Time to Footer
 
I'm trying to put the server time into the footer, so it would read something like this:

All times are GMT +8. The time now is 08:15 AM. | Server Time: 00:15 AM.

I found an article on how to do it for vb3.8 but it doesn't want to work. The article can be found here.

Thanks in advance.

kh99 07-11-2011 12:03 AM

Try using this for the plugin code:
Code:

$server_time = date('h:i:s A');
vB_Template::preRegister('footer', array('server_time' => $server_time))


and then in the template:
HTML Code:

<br />The server time is now {vb:raw server_time}.

vantastic 07-11-2011 12:28 AM

Thanks kh99 - I'm at least now getting a result, albeit an incorrect one, or unexpected one.

Code in html is:
HTML Code:

<div class="below_body">
<div id="footer_time" class="shade footer_time">{vb:rawphrase all_times_are_gmt_x_time_now_is_y} | Server Time: {vb:raw server_time} </div>

The result i'm seeing is:
All times are GMT +8. The time now is 09:18 AM. | Server Time: 08:18 PM

Server time should be 02:18 AM

Perhaps the server is running on a different timezone to GMT? Maybe I need to implement the timezone into the code you gave above?

kh99 07-11-2011 12:37 AM

Yeah, I'm not sure, I just copied the code from that thread you linked to. Reading the docs for date() it seems like your server is probably not set to GMT. I suppose you could just add 6 hours worth of seconds to it, something like date('h:i:s A', time() + 6 * 3600);

vantastic 07-11-2011 12:46 AM

Beautiful! That'll do the trick just nicely. Thanks for your help :)

kh99 07-11-2011 12:53 AM

You're welcome. But apparently I misunderstood the docs - you should be able to use gmdate() instead of date() to get GMT.

vantastic 07-11-2011 01:02 AM

Oh even better. Thanks again! :)


All times are GMT. The time now is 04:02 PM.

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.00918 seconds
  • Memory Usage 1,722KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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