maxso Posted December 5, 2008 Share Posted December 5, 2008 i need a script along the lines of... If the time is between two times (variable) then i need to include a script. If anyone can help or give any links to help me it would be appriechiated. Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/ Share on other sites More sharing options...
Brian W Posted December 5, 2008 Share Posted December 5, 2008 <?php $time = date('G'); if($time > 4 && $time < 6) { $BLAH_BLAH_BLAH } ?> $time will be 0-23 according to http://us2.php.net/date... best of luck Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707143 Share on other sites More sharing options...
premiso Posted December 5, 2008 Share Posted December 5, 2008 <?php $time1 = strtotime('10/27/2008'); $time2 = strtotime('12/6/2008'); $newtime = time(); if ($time1 < $newtime && $time2 > $newtime) { include('script.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707145 Share on other sites More sharing options...
maxso Posted December 5, 2008 Author Share Posted December 5, 2008 tyvm both of you. Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707170 Share on other sites More sharing options...
maxso Posted December 5, 2008 Author Share Posted December 5, 2008 For brian's script, will it still work with... if($time > 4:30 && $time < 4:40) { Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707173 Share on other sites More sharing options...
maxso Posted December 5, 2008 Author Share Posted December 5, 2008 bump Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707200 Share on other sites More sharing options...
premiso Posted December 5, 2008 Share Posted December 5, 2008 You would have to encapsulate it in quotes if it will work or else syntax error. Here is my version that should work with what you want: <?php $time1 = strtotime('4:00 PM'); $time2 = strtotime('4:30 PM'); $newtime = time(); if ($time1 < $newtime && $time2 > $newtime) { include('script.php'); } ?> Unsure if the strtotime will return right, but yea. Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707214 Share on other sites More sharing options...
maxso Posted December 5, 2008 Author Share Posted December 5, 2008 Thanks for your time. Ill put this as solved for now. Link to comment https://forums.phpfreaks.com/topic/135717-solved-a-simple-time-script/#findComment-707229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.