black_box Posted March 5, 2008 Share Posted March 5, 2008 I have a radio program application and I have two text field ONE IS FOR DESCRIPTION ANOTHER IS FOR time User will give description and time for present day and it goes to database Example: Current time: 9:47 Past song: sakira: whenever 9:40 Present song: artist: title On air 9:45 Next Song: James: Bond 10:00 System will take the current time and show on air message for song that is between a range. If the time change then the On air sign will be change and goes to that song which is belogs to current time range. ON AIR WILL BE CHANGE BASED ON SYSTEM TIME Any solution??? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 5, 2008 Share Posted March 5, 2008 <?php $time= time(); if($time=>10:00) { //do stuff } elseif($time<=5:00){ // do stuff } ?> you get the idea Quote Link to comment Share on other sites More sharing options...
black_box Posted March 5, 2008 Author Share Posted March 5, 2008 bt thts not my answer The program will take my system time and compare with user inputs and then if the user input range is within system time like: 9:45 to 10:00 it will show on air for that song if system time is 10:00 then it will change to another song which time is 10:00 Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 5, 2008 Share Posted March 5, 2008 what exactly is the problem i am not understanding the issue at hand ??? Quote Link to comment Share on other sites More sharing options...
black_box Posted March 5, 2008 Author Share Posted March 5, 2008 Ok again i m clearing that: I will insert some song info in the page those data will go to database. An clear example: (but it depends on user input and system time so its dynamic) 9:40 9:45 On air 10:00 The system time is : 9:47 Program will take the system time and search for this time if not found then it will check for the range and the range is 9:45 to 10:00 so it will make 9:45 on air. Got it ? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 5, 2008 Share Posted March 5, 2008 nevermiind i think this is what you are looking for : <?php /** * create_time_range * * @param mixed $start start time, e.g., 9:30am or 9:30 * @param mixed $end end time, e.g., 5:30pm or 17:30 * @param string $by 1 hour, 1 mins, 1 secs, etc. * @access public * @return void */ function create_time_range($start, $end, $by='30 mins') { $start_time = strtotime($start); $end_time = strtotime($end); $current = time(); $add_time = strtotime('+'.$by, $current); $diff = $add_time-$current; $times = array(); while ($start_time < $end_time) { $times[] = $start_time; $start_time += $diff; } $times[] = $start_time; return $times; } // create array of time ranges $times = create_time_range('9:30', '17:30', '30 mins'); // more examples // $times = create_time_range('9:30am', '5:30pm', '30 mins'); // $times = create_time_range('9:30am', '5:30pm', '1 mins'); // $times = create_time_range('9:30am', '5:30pm', '30 secs'); // and so on // format the unix timestamps foreach ($times as $key => $time) { $times[$key] = date('g:i:s', $time); } print '<pre>'. print_r($times, true).'</pre>'; /* * result * Array ( [0] => 9:30:00 [1] => 10:00:00 [2] => 10:30:00 [3] => 11:00:00 [4] => 11:30:00 [5] => 12:00:00 [6] => 12:30:00 [7] => 1:00:00 [8] => 1:30:00 [9] => 2:00:00 [10] => 2:30:00 [11] => 3:00:00 [12] => 3:30:00 [13] => 4:00:00 [14] => 4:30:00 [15] => 5:00:00 [16] => 5:30:00 ) */ ?> Quote Link to comment Share on other sites More sharing options...
black_box Posted March 5, 2008 Author Share Posted March 5, 2008 thanx dark let me try ....thanks a lot for ur time SOLVED Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 5, 2008 Share Posted March 5, 2008 if that doesnt work the above function may work as well just add something like <?php if($times=>9:45) { // on air } elseif ($times<=5:45) { //off air }?> 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.