$weekNum = date("W") - date("W",strtotime(date("Y-m-01"))) + 1;
$dayNum = date('w');
if($dayNum == 0) {
$dayNum = 7;
}
//echo "day: " . $dayNum;
//echo "Today (" . date('l') . ") is in week " . $weekNum . " in " . date('F') . ", where monday is the first day of the week.";
$results = db_query("
SELECT node.nid,
node.title AS node_title,
node.changed AS node_changed,
node_data_field_starttime.field_starttime_value AS node_data_field_starttime_field_starttime_value,
content_field_field_dayofweek.field_field_dayofweek_value dayOfWeek,
content_field_weekofmonth.field_weekofmonth_value weekOfMonth
FROM {node} node
LEFT JOIN {content_type_kser_program} node_data_field_starttime ON node.vid = node_data_field_starttime.vid
LEFT JOIN {content_field_field_dayofweek} on content_field_field_dayofweek.nid = node.nid
LEFT JOIN {content_field_weekofmonth} on content_field_weekofmonth.nid = node.nid
WHERE (node.type IN ('kser_program')) AND (node.status = '1')
ORDER BY node_data_field_starttime_field_starttime_value ASC
");
echo '
';
while ($result = db_fetch_array($results)) {
if($result[weekOfMonth] == $weekNum && $result[dayOfWeek] == $dayNum) {
$hour = substr($result[node_data_field_starttime_field_starttime_value], 0, 2);
$minutes = substr($result[node_data_field_starttime_field_starttime_value], 3, 2);
if( $hour > 11) {
if($hour != 12) {
$hour = $hour - 12;
}
$showTime = $hour . ":" . $minutes . " pm";
}else {
$showTime = $hour . ":" . $minutes . " am";
}
//dpm($result);
echo '- ' . $showTime . ' ' . $result[node_title] . '
';
}
}
echo "
";
?>