I am attempting to implement a feature on my company's website where we have live chat feature available only during our business hours. I am trying to have an image that says "Click to Chat" and that image link to our chat application during the hours between 9am and 5pm and have an image that displays "Chat not available at this time" during all other hours.
I realize that the best way to do this is to use server side coding to make sure that the time always coincides with the hours our office is operational. I have stumbled on this code but it all it does is change in image by the hour.
<?php
$hour = date('H', time()); // Returns the hours of the server time, from 0 to 23.
switch ($hour) {
case '0':
$img = '0.jpg';
break;
case '1':
$img = '1.jpg';
break;
// ... and so on...
}
?>
<img src="<?php echo $img; ?>" />
I was wondering if I can adapt this or any other code to have set time zones in which to:
1) Display a specific image, and
2) Change the link to which the image points to
Thank you for any help you may be able to provide.
I realize that the best way to do this is to use server side coding to make sure that the time always coincides with the hours our office is operational. I have stumbled on this code but it all it does is change in image by the hour.
<?php
$hour = date('H', time()); // Returns the hours of the server time, from 0 to 23.
switch ($hour) {
case '0':
$img = '0.jpg';
break;
case '1':
$img = '1.jpg';
break;
// ... and so on...
}
?>
<img src="<?php echo $img; ?>" />
I was wondering if I can adapt this or any other code to have set time zones in which to:
1) Display a specific image, and
2) Change the link to which the image points to
Thank you for any help you may be able to provide.