Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Action Based Script based on Time
Old 06-29-2008, 11:27 AM Action Based Script based on Time
Average Talker

Posts: 20
Trades: 0
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:
  1. I'm not sure if the timezone is a problem, because the webhost is in the same timezone as we are?
  2. It appears to work as attended, but I'm not sure if it works 100%
  3. 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!!!
slickwilly789 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-29-2008, 03:03 PM Re: Action Based Script based on Time
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I think what you're looking for is something like this:
PHP Code:
if ( $currentday && $cmp_string 800 && $cmp_string 1700 ) {
    echo 
"<span class=\"open\">Kirby Digital is currently Open. In order for us to better assist you, please give us a call at 703.684.7600.</span>";
} else {
    echo 
"<span class=\"closed\">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.</span>";

Does this help?
Note that whenever you enclose a string in double quotes ("), any double quotes in the string must be backslashed like this: \"

Hope this helps.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Action Based Script based on Time
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31795 seconds with 12 queries