Opening Hours

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 14, 2016   (RSS)

By gregThomas - June 14, 2016

Hey Tim, 

I think something like this should work:

<?php

// OPENING HOURS
$today      = date("l");
$todayDate  = date("m-d 00:00:00");
$todayHours ='';

// find 'special_dates' if today
list($special_datesRecords, $special_datesMetaData) = getRecords(array(
'tableName' => 'special_dates',
'where'     => "`date` LIKE '%".$todayDate."'", // load first record
'limit'     => '1',
));
$special_datesRecord = @$special_datesRecords[0]; // get first record

// find standard opening hours 
list($opening_hoursRecords, $opening_hoursMetaData) = getRecords(array(
'tableName' => 'opening_hours',
));
$opening_hoursRecord = @$opening_hoursRecords[0]; // get first record

// Display special hours, or todays hours
if ($special_datesRecords) { $todayHours=$special_datesRecord['content'];}
else{
  $todayHours = $opening_hoursRecord[strtolower($today)];
}

So I've updated the $todayDate variable so that it gets everything but the current year. Then I've added a where statement that will search the special_dates date field for anything that matches on everything but the year. 

Cheers!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - June 14, 2016

Perfect - thanks mate!

Cheers,

Tim (toledoh.com.au)