This is a crude PHP Script, you will need first to have notions about WordPress hooks
to implement it for example in a Plugin. Please learn about these topics.
Well, in response to your comment, that depends on the workflow of your project/website, to know exactly at what point fire the code.
This is an example, and not necessary should work as you expect
Basically, it should look like this code :
add_action( 'init', 'openning_hours_func' );
function openning_hours_func() {
date_default_timezone_set('Europe/Stockholm'); // timezone
$weekday = date(l); // today
//print $weekday; // Debug
//print date("H:i"); // debug
// Set open and closing time for each day of the week
if ($weekday == "Friday") {
$open_from = "11:00";
$opten_to = "21:45";
}
elseif ($weekday == "Saturday" || $weekday == "Sunday") {
$open_from = "12:00";
$open_to = "21:45";
}
else {
$open_from = "11:00";
$open_to = "20:45";
}
// now check if the current time is before or after opening hours
if (date("H:i") < $open_from || date("H:i") > $open_to ) {
print "Closed!";
}
// show the checkout button
else {
print "Open!";
}
}