I am working on a radio panel, where DJ's can log in and book a slot to go on air. The only issue is - that if someone books a slot at 3AM GMT, and then changes their timezone to GMT+10, it goes backwards where it should go forward..

PHP Code:
$query8  = $db->query( "SELECT * FROM timezones WHERE title = '{$user->data['timezone']}'" );
$array8  = $db->assoc( $query8 );
 
        define("My_TZ", "{$user->data['timezone']}");
        function TZ_Math($Num)
        {
                if(My_TZ == "GMT")
                {
                        $o = $Num;
                        for($i = 0; $i > 0; $i++)
                        {
                                if($i < 23)
                                {
                                        $o++;
                                }
                                else
                                {
                                        $o = 0;
                                }
                        }
                       
                        return $o;
                }
                else
                {
                        return $Num;
                }
        }
       
                $query5 = $db->query( "SELECT * FROM days ORDER BY id" );
                $num5   = $db->num( $query5 );
 
 
                while( $array5 = $db->assoc( $query5 ) ) {
                $i = $array5['day'];
                $day = strtotime( "{$i} october 2012" );
                $day = date( "l", $day );
               
?>
 
<div class="box">
 
        <div class="square title" style="margin-bottom: 0px; cursor: pointer;" onclick="Radi.timetableToggle('<?php echo $i?>'); return false;">
               
                <img id="toggle_<?php echo $i?>" class="toggle" src="_img/<?php echo $i == "minus" "plus"?>.png" alt="Toggle" align="right" />
 
                <strong><?php echo $day?></strong>
               
        </div>
 
        <div id="day_<?php echo $i?>" class="day"<?php if($i != ) { ?> style="display: none;"<?php ?>>
               
                <table width="100%" cellpadding="3" cellspacing="0">
               
                        <tr>
                       
                                <td width="20%" valign="top">
                                <?php
                                       
                                        $k 
1;
                                       
                                        for( 
$j 0$j <= 23$j++ ) {
                                               
                                                if( 
$j 10 ) {
                                               
                                                        
$time "0{$j}:00";
                                               
                                                }
                                                else {
                                               
                                                        
$time "{$j}:00";
                                               
                                                }
 
                                                if( 
$array8['symbol'] == "-" ) {
 
                                                        
$tza TZ_Math($j) - $array8['value'];
 
if (
$tza == "24:00" || $tza == "25:00" || $tza == "26:00" || $tza == "27:00" || $tza == "28:00" || $tza == "29:00" || $tza == "30:00" || $tza == "31:00" || $tza == "32:00" || $tza == "33:00" || $tza == "34:00" || $tza == "35:00" || $tza == "36:00"){
if (
$day == "Monday"){
$i 2;
}
else if (
$day == "Tuesday"){
$i 3;
}
else if (
$day == "Wednesday"){
$i 4;
}
else if (
$day == "Thursday"){
$i 5;
}
else if (
$day == "Friday"){
$i 6;
}
else if (
$day == "Saturday"){
$i 7;
}
else if (
$day == "Sunday"){
$i 1;
}
}
if (
$tza == "24:00"){ $tza "0";}
if (
$tza == "25:00"){ $tza "1";}
if (
$tza == "26:00"){ $tza "2";}
if (
$tza == "27:00"){ $tza "3";}
if (
$tza == "28:00"){ $tza "4";}
if (
$tza == "29:00"){ $tza "5";}
if (
$tza == "30:00"){ $tza "6";}
if (
$tza == "31:00"){ $tza "7";}
if (
$tza == "32:00"){ $tza "8";}
if (
$tza == "33:00"){ $tza "9";}
if (
$tza == "34:00"){ $tza "10";}
if (
$tza == "35:00"){ $tza "11";}
if (
$tza == "36:00"){ $tza "12";}
 
                                                }elseif( 
$array8['symbol'] == "+" ){
                                                       
                                                        
$tza TZ_Math($j) + $array8['value'];
 
if (
$tza == "24:00" || $tza == "25:00" || $tza == "26:00" || $tza == "27:00" || $tza == "28:00" || $tza == "29:00" || $tza == "30:00" || $tza == "31:00" || $tza == "32:00" || $tza == "33:00" || $tza == "34:00" || $tza == "35:00" || $tza == "36:00"){
if (
$day == "Monday"){
$i 2;
}
else if (
$day == "Tuesday"){
$i 3;
}
else if (
$day == "Wednesday"){
$i 4;
}
else if (
$day == "Thursday"){
$i 5;
}
else if (
$day == "Friday"){
$i 6;
}
else if (
$day == "Saturday"){
$i 7;
}
else if (
$day == "Sunday"){
$i 1;
}
}
if (
$tza == "24:00"){ $tza "0";}
if (
$tza == "25:00"){ $tza "1";}
if (
$tza == "26:00"){ $tza "2";}
if (
$tza == "27:00"){ $tza "3";}
if (
$tza == "28:00"){ $tza "4";}
if (
$tza == "29:00"){ $tza "5";}
if (
$tza == "30:00"){ $tza "6";}
if (
$tza == "31:00"){ $tza "7";}
if (
$tza == "32:00"){ $tza "8";}
if (
$tza == "33:00"){ $tza "9";}
if (
$tza == "34:00"){ $tza "10";}
if (
$tza == "35:00"){ $tza "11";}
if (
$tza == "36:00"){ $tza "12";}
                                                       
                                                }else{
                                                        
$tza TZ_Math($j);
                                                }
                                               
                                                
$query $db->query"SELECT * FROM timetable WHERE day = '{$i}' AND time = '{$tza}'" );
                                                
$array $db->assoc$query );
                                                
$num   $db->num$query );
 
                                                
$query2 $db->query"SELECT * FROM users WHERE id = '{$array['dj']}'" );
                                                
$array2 $db->assoc$query2 );
 
                                                
$query3 $db->query"SELECT * FROM usergroups WHERE id = '{$array2['displaygroup']}'" );
                                                
$array3 $db->assoc$query3 );
 
                                                echo 
"<div style=\"padding: 3px;\">";
                                               
                                                echo 
$time;
                                                echo 
" - ";
                                               
                                                if( 
$num == ) {