vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Beta Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=5)
-   -   My first one - the standards/cities of timezone display (https://vborg.vbsupport.ru/showthread.php?t=34896)

Stoned Gecko 02-08-2002 10:00 PM

Preface:
I wanted to display the actual timezone text on the forum in addition to the GMT offset. Since I couldn't find anything here, I did it myself. Now I'm sure there is an easier way of doing this, however I have never touched PHP before. So this is the only way I could figure out how to do this. However since I managed to do it, I thought I'd share it :).

What it does:
This basically creates a $timezonetext variable that can be used in templates. The variable contains the text for the appropriate timezone the user selected. For example if the user selected GMT -8, $timezone would contain "US/Pacific Time (US & Canada)".

What it looks like:
The contents of the timezone template:
http://forums.sygatetech.com/tzhack/tztemp.gif

The text generated by that (sorry, live demo is not up yet :))
http://forums.sygatetech.com/tzhack/tzss.gif


What to do:

Edit global.php. Find this text:

PHP Code:

$timediff='';
if (
$bbuserinfo['timezoneoffset']!=0) {
  if (
abs($bbuserinfo['timezoneoffset'])==1) {
    
$timediff=$bbuserinfo[timezoneoffset] hour";
  } else {
    
$timediff=$bbuserinfo[timezoneoffset] hours";
  }


Then right below that add this:

PHP Code:

switch ($bbuserinfo['timezoneoffset']) {

    case (-
12):
        
$timezonetext="Eniwetok, Kwajalein";
    break;

    case (-
11):
        
$timezonetext="Midway Island, Samoa";
    break;

    case (-
10):
        
$timezonetext="US-Hawaii";
    break;

    case (-
9):
        
$timezonetext="US-Alaska";
    break;

    case (-
8):
        
$timezonetext="US/Pacific Time (US & Canada)";
    break;

    case (-
7):
        
$timezonetext="US/Mountain Time (US & Canada)";
    break;

    case (-
6):
        
$timezonetext="US/Central Time (US & Canada), Mexico City";
    break;

    case (-
5):
        
$timezonetext="US/Eastern Time (US & Canada)";
    break;

    case (-
4):
        
$timezonetext="Atlantic Time (Canada), Caracas, La Paz";
    break;

    case (-
3.5):
        
$timezonetext="Newfoundland";

    case (-
3):
        
$timezonetext="Brazil, Buenos Aires, Georgetown";
    break;

    case (-
2):
        
$timezonetext="Mid-Atlantic";
    break;

    case (-
1):
        
$timezonetext="Azores, Cape Verde Islands";
    break;

    case (
0):
        
$timezonetext="Western Europe Time, London, Casablanca";
    break;

    case (
1):
        
$timezonetext="Central Europe Time, Brussels, Copenhagen, Paris";
    break;

    case (
2):
        
$timezonetext="Eastern Europe Time, Kaliningrad, South Africa";
    break;

    case (
3):
        
$timezonetext="Moscow, St. Petersburg, Baghdad, Kuwait";
    break;

    case (
3.5):
        
$timezonetext="Tehran";
    break;

    case (
4):
        
$timezonetext="Muscat, Baku, Tbilisi";
    break;

    case (
4.5):
        
$timezonetext="Kabul";
    break;

    case (
5):
        
$timezonetext="Ekaterinburg, Islamabad";
    break;

    case (
5.5):
        
$timezonetext="Bombay, New Delhi";
    break;

    case (
6):
        
$timezonetext="Almaty, Dhaka";
    break;

    case (
7):
        
$timezonetext="Bangkok, Hanoi";
    break;

    case (
8):
        
$timezonetext="Beijing, Perth, Singapore, Hong Kong";

    case (
9):
        
$timezonetext="Tokyo, Seoul, Osaka";
    break;

    case (
9.5):
        
$timezonetext="Adelaide, Darwin";
    break;

    case (
10):
        
$timezonetext="Eastern Australian Standard, Guam, Papua New Guinea, Vladivostok";
    break;

    case (
11):
        
$timezonetext="Magadan, Solomon Islands";
    break;

    case (
12):
        
$timezonetext="Auckland, Wellington, Fiji, Kamchatka";
    break;



Hope someone finds this usefull besides me. :D

LuBi 02-10-2002 01:09 AM

Sounds good, have an ss?

Stoned Gecko 02-10-2002 01:40 AM

What's an SS? :confused:

Floris 02-10-2002 08:58 AM

SS (ScreenShot)

Stoned Gecko 02-13-2002 12:53 AM

Sorry for the lag. Screen shots are on the top post.


All times are GMT. The time now is 08:31 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.01121 seconds
  • Memory Usage 1,752KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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