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.