Hello,
Well I've decided to dive into php coding, I'm a noob so bear with me!
This script is supposed to display a message, in a given style'd div class, based on a the current time and a range of days and hours.
Basically, it is supposed to say "open" Mon-Friday (8am to 5pm) and closed Mon-Friday (5pm - 8am) & Friday - Monday morning up to 8am. A regular working week.
My questions: - I'm not sure if the timezone is a problem, because the webhost is in the same timezone as we are?
- It appears to work as attended, but I'm not sure if it works 100%
- How can I apply different CSS classes to the two different messages, IE... red background for the echo "closed" and Green for the "Open" message?
Code:
<style type="text/css">
<!--
.closed_error {border: 1px solid #777; color: #fff; Margin: 20px 0 20px 0; padding: 5px 10px 5px 10px; background:#ff4f4f; width: 495px;}
-->
</style>
<div class="closed_error"><p>
<?php
$today = date_create();
$cmp_string = date_format($today, 'Gi');
$currentday = date("N");
if ( $currentday < 6 && $cmp_string > 800 && $cmp_string < 1700 ) {
echo "Kirby Digital is currently Open. In order for us to better assist you, please give us a call at 703.684.7600.";
} else {
echo "Kirby Digital is currently Closed. We are open Monday - Friday, between the hours of 8:00am and 5:00pm. Please leave us a message on 703.684.7600 or Contact us VIA our Online form.";
}
?>
</div>
Any help is much appreciated! Can't wait to get "decent" at php!!!
|