MSFN Forum: how to change image according to time (PHP) - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

how to change image according to time (PHP) changing image according to time with minutes Rate Topic: -----

#1 User is offline   sanjeev18 

  • Great Helper
  • Pip
  • Group: Members
  • Posts: 71
  • Joined: 11-October 10
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 10 November 2012 - 02:21 AM

I am working on Radio website where i have to show image of program that's on air according to name of day and time. i made something that works but it works for hours not for minutes. i want it to be shown by minutes
like some program is from 04:30AM to 05:00AM. my code only works for hours like 04:00 AM to 05:00AM..

i created a function that gets program name according to name of day.

here's is how my code looks like



function get_program_name($name_of_day){ //
   date_default_timezone_set('Asia/Kathmandu'); //Asia/Kathmandu.
   $timehour=date('h');
   switch ($name_of_day) { //switching case starts here

      case 'Sunday':
 		if (05<=$timehour && &timehour <06) { // 05:00AM to 06:00AM
   			$current_program='current_program.jpg';
   			$upcoming_program='upcoming_program.jpg'

            elseif (06<=$timehour && timehour <07) { // 06:00AM to 07:00AM
   			$current_program='current_program.jpg';
   			$upcoming_program='upcoming_program.jpg'
            }
 		}
 		break;
      
      case 'Monday':
 		
 		break;

      case 'Tuesday':
        
 		break;

      case 'Wednesday':
 		
 		break;

      case 'Thrusday':
 		
 		break;

      case 'Friday':
 		
 		break;

      case 'Saturday':
 		
 		break;

      default:
 		echo "Something went wrong!!";
 		break;
   }//case closes here
}//function closes here
   get_program_name('Sunday');





thanks in advanced..

This post has been edited by sanjeev18: 10 November 2012 - 02:27 AM



#2 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,669
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 28 November 2012 - 09:24 AM

There are predefined PHP functions to get the time, including minutes.
http://www.php.net/m...constants.types

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy