"; print_r($str); print ""; } function printStyle() { ?> open($sql); $index = -1; while($row = $db->row()) { $index++; ?>
Make sure you adjust the Time Zone for Your Time Zone

 

open($sql_sunday); $sundate_arr = $db->row(); $sunday = date('Y-m-d H:i:s', TZConvert(strtotime($sundate_arr['sunday'] . " 00:00"), 2, $gmt_offset)); // *************************************************************************************** // we could just forget the date, because these are weekly events // and just take the the week day and the time and minuz the offset // *************************************************************************************** // 1. get the date // 2. minus the offset // 3. get the date of last sunday // the = six hours is now() - server time + 2 $sql = "select date_format(now() + interval " . ($gmt_offset + 6) . " hour, '%Y-%m-%d') as 'date', " . "date_format(now() + interval " . ($gmt_offset + 6) . " hour, '%h:%i:%s') as 'time', " . "date_format(now() + interval " . ($gmt_offset + 6) . " hour, '%W') as 'dayname'"; //prent($sql); $db->open($sql, 1); $date_arr = $db->row(); $sunDate = $date_arr['date']; $sunDay = $date_arr['dayname']; $sunTime = $date_arr['time']; //prent($sunDate . " " . $sunTime . " " . $sunDay); if($sunDay != "Sunday") { // we have to get the date of the Sunday of that week. $sql2 = " select date_format('$sunDate' - interval date_format('$sunDate', '%w') day, '%Y-%m-%d') as 'sunday', date_format('$sunDate' - interval date_format('$sunDate', '%w') day, '%h:%i:%s') as 'time' "; //prent($sql2); $db2->open($sql2, 1); $newDateArr = $db2->row(); //prent($newDateArr); $sunDate = $newDateArr['sunday']; $sunDay = "Sunday"; $sunTime = $newDateArr['time']; } //prent($sunDate . " " . $sunTime . " " . $sunDay); // now we need to grab a selection of that weeks details $sql3 = ""; // *************************************************************************************** $sql4 = " SELECT et.eventid as 'id', e.name as 'name', et.eventdate as 'date', et.eventtime as 'time', et.eventday as 'day', HOUR(et.eventtime) as 'hour' FROM eventtime et left join event e on e.id = et.eventid -- WHERE eventday = date_format('$sunDate', '%W') "; //prent($sql4); $db->open($sql4); $events = getEvents($db); //prent($events); for($i=0; $i<24; $i++) { ?>
Select Timezone:  
SundayMondayTuesdayWednesdayThursdayFridaySaturday
">">
row()) { $i++; $dbDay = $row['day']; $dbHour = $row['hour']; $newDate = date("Y-m-d H:i:s", TZConvert(makeMyDay($dbDay, $row['time']), 2, $gmt_offset)); preg_match("/(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/", $newDate, $splitted); list($all,$year,$month,$day,$hour,$min,$sec) = $splitted; $hour = (int)$hour; $dayname = calculateDayOffset("$year-$month-$day $hour:$min", $gmt_offset); $events[$dayname][$hour][$i]['id'] = $row['id']; $events[$dayname][$hour][$i]['name'] = $row['name']; $events[$dayname][$hour][$i]['date'] = "$year-$month-$day"; $events[$dayname][$hour][$i]['time'] = "$hour:$min"; $events[$dayname][$hour][$i]['day'] = $dayname; $events[$dayname][$hour][$i]['hour'] = $hour; } return $events; } // pics all events for certgain hour function getEvent($events, $day, $hour) { $days = array( 1 => "Sunday", 2 => "Monday", 3 => "Tuesday", 4 => "Wednesday", 5 => "Thursday", 6 => "Friday", 7 => "Saturday" ); // $day 4 = wed // $hour 10 = 10:00 $event = ""; if(isset($events[$days[$day]][$hour])) { $event = $events[$days[$day]][$hour]; } return $event; } function calculateDayOffset($mysqlDate, $gmt_offset) { global $db2; $days = array( 1 => "Sunday", 2 => "Monday", 3 => "Tuesday", 4 => "Wednesday", 5 => "Thursday", 6 => "Friday", 7 => "Saturday" ); //$sql = "SELECT DATE_FORMAT('" . date('Y-m-d H:i:s', TZConvert(strtotime($mysqlDate), 2, $gmt_offset)) . "', '%W') as 'daynum'"; $sql = "SELECT DATE_FORMAT('" . date('Y-m-d H:i:s', strtotime($mysqlDate)) . "', '%W') as 'daynum'"; //prent($sql); $db2->open($sql); $row = $db2->row(); return $row['daynum']; } function connect() { global $config; $db = new DBTable($config); $db->ReadXMLConfig($config['config_file']); $samlogin = $db->login; $db->connect(); return $db; } function TZConvert($fromTimeStamp, $fromOffset, $toOffset) { $newtt = null; $dir = null; $hour = 60 * 60; $from = $fromOffset * $hour; $to = $toOffset * $hour; $fromtt = $fromTimeStamp; if($from < $to) { $newtt = $fromtt + ($to - $from); } else if($from > $to) { $newtt = $fromtt + ($to - $from); } else { $newtt = $fromtt; } return $newtt; } print("
Server time: " . date('l dS \of F Y h:i:s A') . "
"); function getTimezoneList() { ?>