mcmuney Posted March 18, 2009 Share Posted March 18, 2009 1) I'm looking for a script that will pull current time and then determine if the current hour is an odd or even number... if odd, then do A, if even do B. 2) Based on #1 above, instead of odd and even, would like to use if then based on minute range. For example, if minute is between 1-5, do A else do B. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/149940-solved-time/ Share on other sites More sharing options...
Daniel0 Posted March 18, 2009 Share Posted March 18, 2009 1) if (date('h') % 2 != 0) { // do A } else { // do B } 2) if (in_array(date('i'), range(1, 5)) { // do A } else { // do B } Quote Link to comment https://forums.phpfreaks.com/topic/149940-solved-time/#findComment-787477 Share on other sites More sharing options...
rameshfaj Posted March 18, 2009 Share Posted March 18, 2009 I think there is time() method in php. This gives the total time in seconds.You can manipulate accordingly. $curr_time=date("H:i:s"); http://www.php.net/time Quote Link to comment https://forums.phpfreaks.com/topic/149940-solved-time/#findComment-787488 Share on other sites More sharing options...
Daniel0 Posted March 18, 2009 Share Posted March 18, 2009 Good job providing a less complete solution... Quote Link to comment https://forums.phpfreaks.com/topic/149940-solved-time/#findComment-787490 Share on other sites More sharing options...
rameshfaj Posted March 18, 2009 Share Posted March 18, 2009 Ya though it is less complete and clean in comparison to yours, I hope it might be helpful in other related problems too. Quote Link to comment https://forums.phpfreaks.com/topic/149940-solved-time/#findComment-787496 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.