Web Hosting Talk







View Full Version : NEED: Script to display graphic based upon time


robertk1
10-31-2008, 05:18 PM
NEED: Script to display graphic based upon time

I need a small script that will display graphic-A furing hours 1-9 and graphic-B during hours 10-24. Anybody know of a simple script that will do this? Better yet, if we can select times based upon the day of thew week, it would be even better!
I tried searching, but didn't inf anything resembling this. The coding will be added to a product description in osCommerce, which accepts html coding easily but other scripting types may or may not work. I want an OPEN graphic to display during normal business hours, and CLOSED when outside these hours.
Thanks in advance!





__________________
Custom Web Site Designs
eCommerce

linux-tech
10-31-2008, 05:24 PM
Use php and the date function. Using misc variables, you can detect the hour of the day, even using a switch($hour) statement to tell what image to show in what hour.





__________________Linux Tech Networks: Reliable Server Administration and Monitoring since 2002VBulletin Development: VBulletin customizations, development, hosting and leased licenses

robertk1
10-31-2008, 05:36 PM
Hmmm, sounds logical, but outside my area of expertise.
Thanks for the reply





__________________
Custom Web Site Designs
eCommerce

Steve_Arm
10-31-2008, 05:37 PM
PHP Code:



<?$hour = (int) date('H');$day = date('D')echo '<img src="'.pick_according_to_day($hour, $day).'" />';function pick_according_to_day($hour, $day){テつ*テつ*テつ*$graph = 'graphic-a';テつ*テつ*テつ*テつ*switch ($day)テつ*テつ*テつ*テつ*{テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*case 'Sun': if ($hour > 1 テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*break;テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*case 'Mon': if ($hour > 2 テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*break;テつ*テつ*テつ*テつ*テつ*テつ*テつ*テつ*default:テつ*テつ*テつ*テつ*}テつ*テつ*テつ*テつ*return $graph;}?>










__________________
PHP Code Repository | Worst Wide Web, now PR2

robertk1
11-01-2008, 06:40 AM
Hmmm, that looks good. I have to tinker a bit to get it to run like a html script in oscommerce, but thank you for the start!





__________________
Custom Web Site Designs
eCommerce

justsurge
11-02-2008, 12:01 PM
you need to use javascript, sorry - php-perl, show the server time, not actual time from visitor, so in atlanta the website shows 10 - but the user in japan is really at 4 hours earlier, 6 am?
its a small piece of js for you, from http://javascriptkit.com/
eliot





__________________pentiume.com Computer Services, Repairs and Emergency services, Home computers, programming,

robertk1
11-03-2008, 09:45 AM
Thanks for the tip!





__________________
Custom Web Site Designs
eCommerce