jiggles Posted December 21, 2009 Share Posted December 21, 2009 Hi, Just having some problems executing this script. Can someone see what I am doing wrong ? Thanks in advanced <?php $time = date("Hi"); //returns HoursMinutes if( ($time >= "0000" && $time < "0000") || ($time >= "0000" && $time < "0000") || ($time >= "0000" && $time < "0000") ) { header("Location: REDIRECT URL"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/185845-redirect-based-on-time/ Share on other sites More sharing options...
oni-kun Posted December 21, 2009 Share Posted December 21, 2009 Basically but what is with your OR and AND statements? You're saying if the date is larger than 0, equal to 0, or greater than 0 it'll redirect. Doesn't matter what you replace the time with, it'll always run. You need to use IF/ELSE's the proper way, if you want an example tell us more what you're trying to do and we'd be glad to write you one. Quote Link to comment https://forums.phpfreaks.com/topic/185845-redirect-based-on-time/#findComment-981322 Share on other sites More sharing options...
jiggles Posted December 21, 2009 Author Share Posted December 21, 2009 Hi, Thanks for your quick response. I just wanted to between the times (server time) 7:00am-9:00am & 5.00pm-7.00pm to do nothing so they can access that certain page. Any other times it will redirect the user back out to the main page index.php. So, I was going to have >"0000" && <"7000" || >"9000" <"1700" etc... for the other times to do a redirect. Quote Link to comment https://forums.phpfreaks.com/topic/185845-redirect-based-on-time/#findComment-981847 Share on other sites More sharing options...
jiggles Posted December 22, 2009 Author Share Posted December 22, 2009 Is something like this more suitable ? <?php $time = date("Hi"); //returns Hours & mins if($time >= 0000 && $time <= 0700) header("Location: http://www.something.index.php"); else if($time >= 0900 && $time <= 1700) header("Location: http://www.something.index.php"); else if($time >= 1900 && $time <= 2359) header("Location: http://www.something.index.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/185845-redirect-based-on-time/#findComment-982739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.