Im kind'of stuck on my project...can you help me?
What i'm trying to do is to echo in two different places either the variable $open_text
and $open_image
OR $close_text
and $close_image
based on current day and hour from the
first statement.
I've already tried with switch -> case
but it didn't work. Another idea was to use variables variable but i dont quite know how to adapt it to my project.
What i have is:
<?php
date_default_timezone_set('Europe/Rome'); // timezone
$weekday = date(l); // today
// Set open and closing time for each day of the week
if ($weekday == "Tuesday" || $weekday == "Wednesday" || $weekday == "Thursday" || $weekday == "Friday" || $weekday == "Saturday") {
$morning_open_from = "09:15";
$morning_open_to = "12:30";
$afternoon_open_from = "15:00";
$afternoon_open_to = "19:30";
}
else {
$morning_open_from = "00:00";
$morning_open_to = "00:00";
$afternoon_open_from = "00:00";
$afternoon_open_to = "00:00";
}
// check if the current time is before or after opening hours
if (date("H:i") > $morning_open_from || date("H:i") < $morning_open_to && date("H:i") > $afternoon_open_from || date("H:i") < $afternoon_open_to ) {
$open_text = "<span style='font-size:14px; color: green;'>We're open, call us!</span>";
$open_image = "<span style='font-size:20px; color: #000; font-family: Arial,Verdana,sans-serif;'>0123.456789</span>";
}
// show the checkout button
else {
$close_text = "<span style='font-size:14px; color: red;'>We're closed, contact us!</span>";
$close_image = "<span style='font-size:20px; color: #000; font-family: Arial,Verdana,sans-serif;'>webmaster@webmaster.com</span>";
}
?>
Thank you very much.