PHP Newb issue with time and date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
taffey01
Forum Newbie
Posts: 2
Joined: Fri Aug 21, 2009 7:06 am

PHP Newb issue with time and date

Post by taffey01 »

Hi there,
This will probably be easy for you guys.

I'm trying to run an echo print based on a certain time and the actual day.

Required values are after 5pm and before 9am and on a Sat or Sun.

This is what i have but it doesnt work properly. Any pointers?

$today = date("w");
$current_time = date(G);

if ( $current_time < 9 || current_time > 17 || $today==0 || $today==6) {
echo "I'm sorry you have reached us out of hours!<br> Please try again between Mon-Fri 9am-5pm.";
exit;
}

Thanks in advance..
User avatar
juma929
Forum Commoner
Posts: 72
Joined: Wed Jun 17, 2009 9:41 am

Re: PHP Newb issue with time and date

Post by juma929 »

Hello,
if ( $current_time < 9 || current_time > 17 || $today==0 || $today==6) {
Change to
if ( $current_time < 9 || $current_time > 17 || $today==0 || $today==6) {
Let me know if that helps, also try enabling error reporting etc so you can see.

8O
taffey01
Forum Newbie
Posts: 2
Joined: Fri Aug 21, 2009 7:06 am

Re: PHP Newb issue with time and date

Post by taffey01 »

Thanks for the reply. I see i missed the $ sign.

Ha ha maybe thats it..
Post Reply