Opening hours / Online / Offline

Hello , Is it possible if someone could show me a example code of how i would write the below scenario please

We run a web hosting company and we have online chat - our online chat is run mon - sun , 9:00am - 5:00PM

outside of these hours we want it to show a message like “Live Support Offline - Office Closed”

=======================================

<?php //If something changes, do it here $Hours[Monday]="9am - 5pm"; $Hours[Tuesday]="9am - 5pm"; $Hours[Wednesday]="9am - 5pm"; $Hours[Thursday]="9am - 5pm"; $Hours[Friday]="9am - 5pm"; $Hours[Saturday]="9am - 4pm"; $Hours[Sunday]="10am - 2pm"; $phoneNumber="(02) 47 222 660"; //Function code bellow. //Functions function singlelineOpeningHours() { global $Hours; echo "Mon - Fri " . $Hours[Monday] . ", Sat " . $Hours[Saturday] . ", Sun " . $Hours[Sunday] . "
"; } function multilineOpeningHours() { global $Hours; $today=date("l"); $week=array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"); foreach ($week as $day) { if ($day==$today) echo "" . $day . " " . $Hours[$day] . ""; else echo $day . " " . $Hours[$day]; echo "
"; } } function phoneNumber() { global $phoneNumber; echo $phoneNumber . "
"; } ====================================== The above code i provided i found on another website and i thought id post it here to see if it was any use for you in answering my question thanks daniel

Hey,

If it’s always the same, you can simple put:

[php]
echo (date(“H”) > 09 && date(“H”) < 17) ? “online” : “offline”;
[/php]

Let me know if this helps or if you get any problems.

Sponsor our Newsletter | Privacy Policy | Terms of Service