Page 1 of 1

PHP Newb issue with time and date

Posted: Fri Aug 21, 2009 7:10 am
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..

Re: PHP Newb issue with time and date

Posted: Fri Aug 21, 2009 7:19 am
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

Re: PHP Newb issue with time and date

Posted: Fri Aug 21, 2009 4:06 pm
by taffey01
Thanks for the reply. I see i missed the $ sign.

Ha ha maybe thats it..