SunQuest
           Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old March 12th, 2006, 10:23 AM
Cerebral Stasis Cerebral Stasis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 Cerebral Stasis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 38 sec
Reputation Power: 0
Timezone Offset Script - Help Requested

I run a fansite, nhbfan.com, that has a schedule of live shows, currently only in EST. However, this Internet radio station gets listeners from across the globe. So, I attempted to come up with a script that would allow one to add/subtract an offset from each show time according to what one selects one's timezone as, automatically subtract daylight savings time values, and saves the choice as a perminant cookie. However, I haven't been able to get it to work correctly. Here is what I've got so far. If you need to see the schedule, go to nhbfan.com and look to the left, under "Shows."

Since this is a "rough draft" of the script, the only two files involved are index.php and schedule.php.

This is the first file: it should allow one to select one's time zone, although it doesn't seem to work, and I would like the drop-down list to have more description (i.e. "Eastern Standard Time (GMT - 5)").

Code:
<html><body>
Select your GMT offset.
<form action="schedule.php" method="post">
<select name="offset">
<option>- 12</option>
<option>- 11</option>
<option>- 10</option>
<option>- 9</option>
<option>- 8</option>
<option>- 7</option>
<option>- 6</option>
<option>- 5</option>
<option>- 4</option>
<option>- 3</option>
<option>- 2</option>
<option>- 1</option>
<option>0</option>
<option>+ 1</option>
<option>+ 2</option>
<option>+ 3</option>
<option>+ 4</option>
<option>+ 5</option>
<option>+ 6</option>
<option>+ 7</option>
<option>+ 8</option>
<option>+ 9</option>
<option>+ 10</option>
<option>+ 11</option>
<option>+ 12</option>
<option>+ 13</option>
</select>
<input type="submit" />
</form>
</body></html>


Below is the script itself. I am not sure how to work the daylight savings time or cookie parts, since I am very new to coding PHP, but it SHOULD offset the time, AM/PM, and weekday in accordance to one's time zone versus live show time. Keep in mind that, so far, I have only set it up to show the first show, for simplicity's sake (well, sort of):

Code:
<?php

// the start and end times for each show is defined
$time["dab"] = 13;
$time["dab2"] = 15;
$time["str"] = 15;
$time["str2"] = 17;
$time["sc"] = 15;
$time["sc2"] = 17;
$time["nhb"] = 15;
$time["nhb2"] = 18;
$time["tap"] = 15;
$time["tap2"] = 17;
$time["tgs"] = 15;
$time["tgs2"] = 17;
$time["tda"] = 17;
$time["tda2"] = 19;
$time["tss"] = 6;
$time["tss2"] = 9;
$time["dr"] = 10;
$time["dr2"] = 12;
$time["tah"] = 12;
$time["tah2"] = 15;
$time["tioli"] = 15;
$time["tioli2"] = 18;
$time["rr"] = 18;
$time["rr2"] = 21;

// the offset is added to the time
$time[$z] = $time[$z] + $offset;

// if the total time is greater than 24 hours, the day is switched one day ahead and 24 hours are subtracted
// if the total time is less than 24 hours, the day is switched one day behind and 24 hours are added
if ( $time[$z] > 24 ){
   $time[$z] = $time[$z] - 24;
   $day[$y] = $day[$y + 1];
} elseif ( $time[$z] < 24 ){
   $time[$z] = $time[$z] + 24;
   $day[$y] = $day[$y - 1];
}

// the am/pm is defined
$ampm[1] = "AM";
$ampm[2] = "PM";

// the am/pm for each show is defined
$ampm["dab"] = $ampm[2];
$ampm["dab2"] = $ampm[2];
$ampm["str"] = $ampm[2];
$ampm["str2"] = $ampm[2];
$ampm["sc"] = $ampm[2];
$ampm["sc2"] = $ampm[2];
$ampm["nhb"] = $ampm[2];
$ampm["nhb2"] = $ampm[2];
$ampm["tap"] = $ampm[2];
$ampm["tap2"] = $ampm[2];
$ampm["tgs"] = $ampm[2];
$ampm["tgs2"] = $ampm[2];
$ampm["tda"] = $ampm[2];
$ampm["tda2"] = $ampm[2];
$ampm["tss"] = $ampm[1];
$ampm["tss2"] = $ampm[2];
$ampm["dr"] = $ampm[2];
$ampm["dr2"] = $ampm[2];
$ampm["tah"] = $ampm[2];
$ampm["tah2"] = $ampm[2];
$ampm["tioli"] = $ampm[2];
$ampm["tioli2"] = $ampm[2];
$ampm["rr"] = $ampm[2];
$ampm["rr2"] = $ampm[1];

// if the time is greater than 12 hours, the am/pm is swapped
// ditto if there are less than 12 hours
if ( $time[$z] > 12 ){
   $time[$z] = $time[$z] - 12;
   $ampm[$z] = $ampm[$a + 1];
} elseif ( $time[$z] < 12 ){
   $time[$z] = $time[$z] + 12;
   $ampm[$z] = $ampm[$a - 1];
}

// the am/pm is swapped here
if ( $ampm[$z] < 1 ){
   $ampm[$z] = $ampm[$z] + 2;
} elseif ( $ampm[$z] > 2 ){
   $ampm[$z] = $ampm[$z] -2;
}

// the days for each show are defined
$day["dab"] = 1;
$day["str"] = 2;
$day["sc"] = 3;
$day["nhb"] = 4;
$day["tap"] = 5;
$day["tgs"] = 6;
$day["tda"] = 6;
$day["tss"] = 7;
$day["dr"] = 7;
$day["tah"] = 7;
$day["tioli"] = 7;
$day["rr"] = 7;

// if the shows are shorter or longer than a 7-day week, the day is pushed to the next day
if ( $day[$y] > 7 ){
   $day[$y] = $day[$y - 7];
}
if ( $day[$y] < 7 ){
   $day[$y] = $day[$y + 7];
}

// the day value for each day variable is defined
$day[1] = "Sunday";
$day[2] = "Monday";
$day[3] = "Tuesday";
$day[4] = "Wednesday";
$day[5] = "Thursday";
$day[6] = "Friday";
$day[7] = "Saturday";

// the output is given (in this case, just for the first show)
echo $day[$day["dab"]] . " " . $time["dab"] . $ampm["dab"] . " - " . $time["dab2"] . $ampm["dab2"];
?>


Any help that can be given would be very much appreciated. I need not only assistance with creation, but also optimization. If one could make the script work and add the requested features, I would be very grateful.

Reply With Quote
  #2  
Old March 17th, 2006, 04:18 PM
Cerebral Stasis Cerebral Stasis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 Cerebral Stasis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 38 sec
Reputation Power: 0
Bump.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Timezone Offset Script - Help Requested


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway