Thanks so much for your reply.
I used a snippet of code to define the open and closed times. And then used if and else statements to display the ‘minicart’ and an open sign during open hours and (else) it will show a closed sign during closed hours.
Here is the code I have used to do this:
[php]
<?php
require_once 'library/config.php';
require_once 'library/cart-functions.php';
//Sets Time Zone
date_default_timezone_set('Europe/London');
// Define daily open hours. Must be in 24-hour format, separated by dash. If closed for the day, set to 00:00-00:00
$time_range_mon = '18:00-22:00';
$time_range_tue = '18:00-22:00';
$time_range_wed = '18:00-22:00';
$time_range_thu = '14:00-22:00';
$time_range_fri = '18:00-23:00';
$time_range_sat = '18:00-23:00';
$time_range_sun = '18:00-22:00';
// Place HTML for output here. Image paths or plain text (H1, H2, p) are all acceptable.
$open_output = '
![Come in, we\'re open!]()
';
$closed_output = '
![Sorry, we\'re closed!]()
';
// OPTIONAL: Output current day's open hours
$echo_daily_hours = true; // Switch to FALSE to hide numerical display of current hours
$time_output = 'g A'; // Enter custom time output format (options listed here: http://php.net/manual/en/function.date.php)
$time_separator = ' - '; // Choose how to indicate range (i.e XX - XX, XX to XX, XX until XX)
$closed_text_output = "Closed"; // This will show if $echo_daily_hours is set to true and the current day's time range is set to 00:00-00:00
// Gets current day of week
$status_today = strtolower(date("D"));
// Gets current time of day in 00:00 format
$current_time = date("G:i");
// Makes current time of day computer-readable
$current_time_x = strtotime($current_time);
// Builds an array, assigning user-defined time ranges to each day of week
$all_days = array("mon" => $time_range_mon, "tue" => $time_range_tue, "wed" => $time_range_wed, "thu" => $time_range_thu, "fri" => $time_range_fri, "Sat" => $time_range_sat, "sun" => $time_range_sun);
foreach ($all_days as &$each_day) {
$each_day = explode("-", $each_day);
$each_day[0] = strtotime($each_day[0]);
$each_day[1] = strtotime($each_day[1]);
}
// Defines array of possible days of week
$week_days = array("mon", "tue", "wed", "thu", "fri", "sat", "sun");
// Compares current day of week to possible days of week and determines open vs closed output based on current day and time.
foreach ($week_days as &$each_week_day) {
if ($status_today == $each_week_day) {
echo '
';
if (($all_days[$each_week_day][0] <= $current_time_x) && ($all_days[$each_week_day][1] >= $current_time_x)) {
require_once 'include/miniCart.php';
echo $open_output;
} else {
echo $closed_output;
}
if ($echo_daily_hours) {
echo '
';
if ((date("g", $all_days[$each_week_day][0]) == "12") && (date("g", $all_days[$each_week_day][1]) == "12")) {
echo $closed_text_output;
} else {
echo date($time_output, $all_days[$each_week_day][0]) . $time_separator . date($time_output, $all_days[$each_week_day][1]);
}
echo '';
}
echo '
';
}
}
?>
[/php]