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? Link to comment https://forums.phpfreaks.com/topic/52870-using-strtotime/ 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? Link to comment https://forums.phpfreaks.com/topic/52870-using-strtotime/#findComment-261044 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 Link to comment https://forums.phpfreaks.com/topic/52870-using-strtotime/#findComment-261046 Share on other sites More sharing options...
knowram Posted May 24, 2007 Author Share Posted May 24, 2007 cool thanks Link to comment https://forums.phpfreaks.com/topic/52870-using-strtotime/#findComment-261049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.