knowram Posted May 24, 2007 Share Posted May 24, 2007 Lets say I have a variable $time = 'Apr 30 2007 7:00AM'. Is there a function that I can use or a way of using the strtotime function to see if that variable $time is between the hours of 7am and 7pm? Quote Link to comment Share on other sites More sharing options...
knowram Posted May 24, 2007 Author Share Posted May 24, 2007 And or is there a what to check to see if that $time variable was on say Sunday? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 24, 2007 Share Posted May 24, 2007 You would want to use strtotime() with the date() function to get out the hours in 24 hour time and use that number for your comparison: <?php $time = 'Apr 30 2007 7:00AM'; $hour = date('g',strtotime($time)); if ($hour >= 7 && $hour <= 19) echo $time . ' is between 7 AM and 7 PM<br>'; if (date('l',strtotime($time)) .eqs. "Sunday") echo $time . ' is a Sunday'; // the argument to date() is a small L ?> Ken Quote Link to comment Share on other sites More sharing options...
knowram Posted May 24, 2007 Author Share Posted May 24, 2007 cool thanks Quote Link to comment 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.