Image change by time and day of week.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
srednatonmi
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2008 10:01 pm

Image change by time and day of week.

Post by srednatonmi »

I've searched all over the internet for a script to do this, but haven't found one although I'm sure they are out there. The point is to display an open sign on a company website when they are open for business and closed when they are closed. Day of week must also be included so that it doesn't display open on Sunday. If you have any knowledge of something like this or can help in any way let me know? This is even a script I would pay for if someone here has the skills to develop it.

Thanks,
Anders Haig
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Image change by time and day of week.

Post by superdezign »

I could make that extremely easily. If you're willing to pay, I'm willing to work. ;)
If not, look into the date() function of PHP. It does everything that you're after.
srednatonmi
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2008 10:01 pm

Re: Image change by time and day of week.

Post by srednatonmi »

What would you charge? I am definatly willing to pay, depending on price, I'm not a cheapskate but I don't know how much some of you guys charge 8O . I would have the two images created and I just need the hours put into a script, which I'm guessing I can just add to the website with a php include. If implementation is more difficult I'd need help with that as well.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Image change by time and day of week.

Post by superdezign »

Okay then, I've sent you a PM with my rates.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Image change by time and day of week.

Post by onion2k »

You don't need to pay for something this simple.

Code: Select all

$opening_time = 9;
$closeing_time = 17;
 
$day = date("w");
$hour = date("G");
//$time = date("m");
 
if (date("w")==0) {
  $image = "closed.jpg";
} elseif ($hour < $opening_time or $hour > $closing_time) {
  $image = "closed.jpg";
} else {
  $image = "open.jpg";
}
 
It's a tiny bit trickier if you want to open at different times on different days, or if you close at a time that isn't on an hour, but that's just a case of adding more if..else clauses really.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Image change by time and day of week.

Post by superdezign »

onion2k wrote:You don't need to pay for something this simple.
;_;
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Image change by time and day of week.

Post by onion2k »

superdezign wrote:
onion2k wrote:You don't need to pay for something this simple.
;_;
Well, unless you charge by the minute I don't see how you'd come up with a sensible estimate for this...

;)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Image change by time and day of week.

Post by superdezign »

onion2k wrote:Well, unless you charge by the minute I don't see how you'd come up with a sensible estimate for this...

;)
Hehe. Throwing in a few extra graphics... Implementing it into a system that's likely unfamiliar... I'd make it into an hour. ;)
srednatonmi
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2008 10:01 pm

Re: Image change by time and day of week.

Post by srednatonmi »

I'm not a php guy, so spending a little money instead of learning how to add if then clauses is worth it to me.
Post Reply