Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-28-2005, 09:15 PM   #1
Member (7 bit)
 
Tech Guy's Avatar
 
Join Date: Aug 2004
Location: Charlottetown, PE, Canada
Posts: 86
Send a message via MSN to Tech Guy
Need some help with a piece of PHP code

Ok, I have have a simple PHP code that displays the current time depending on the time offset that I set it. Due to the fact that I'm pretty new at PHP, I have no clue how to do this, but have a general idea, so I wonder if you guys might be able to help me. What I want the code to do, is whenever the time is between 9:00 and 21:30 is prints the text out green, and when the time is not between those two times it prints out red. Not entirely sure how I would go about doing this. TIA.


Justin

Here is the code:

Quote:
$hourdiff = "0"; // hours difference between server time and local time


$timeadjust = ($hourdiff * 60 * 60);

$melbdate = date(" H:i",time() + $timeadjust);

print ("$melbdate");
?>
P.S. I have the open PHP bracket but it doesn't show up in the quote.
Tech Guy is offline   Reply With Quote
Old 08-29-2005, 08:50 AM   #2
Member (7 bit)
 
Tech Guy's Avatar
 
Join Date: Aug 2004
Location: Charlottetown, PE, Canada
Posts: 86
Send a message via MSN to Tech Guy
Well, after looking at the code, and checking on some things, I realized that I could use if statements. I love IF statements . Here is my finished working PHP code .

Quote:
<?php
$hourdiff = "0"; // hours difference between server time and local time


$timeadjust = ($hourdiff * 60 * 60);

$melbdate = date(/" H:i/",time() + $timeadjust);

IF ($melbdate < " 09:00" || $mebdate >= " 21:30")
{
?>
<FONT COLOR="FF0000">
<?php
print ("$melbdate");
}
else
{
?>
<FONT COLOR="33CC00">
<?php
print ("$melbdate");
}

?>
Tech Guy is offline   Reply With Quote
Old 08-29-2005, 08:54 AM   #3
Member (9 bit)
 
Join Date: May 2003
Posts: 420
Send a message via AIM to juicelooser
Looks good--you did forget the l in the second $melbdate in the IF statement though.
juicelooser is offline   Reply With Quote
Old 08-30-2005, 12:18 AM   #4
Member (7 bit)
 
Tech Guy's Avatar
 
Join Date: Aug 2004
Location: Charlottetown, PE, Canada
Posts: 86
Send a message via MSN to Tech Guy
Yeah, I didn't realize that until 9:30 tonight when it didn't change to red, so I went back and realized that it was missing. Spelling mistakes rule.
Tech Guy is offline   Reply With Quote
Old 08-30-2005, 07:43 AM   #5
Member (9 bit)
 
Join Date: May 2003
Posts: 420
Send a message via AIM to juicelooser
They're the worst, especially if you don't notice it right away. I've yelled at my computer for hours before realizing I spelled the variable wrong.
juicelooser is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:56 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2