Hello,
I want to use php to put a note on a site saying "we are open, call now" (or whatever) if the time is between 7:30am and 4:00pm Monday to Friday.
Any help/direction is much appreciated.
Thanks!
Ida
| SitePoint Sponsor |
Hello,
I want to use php to put a note on a site saying "we are open, call now" (or whatever) if the time is between 7:30am and 4:00pm Monday to Friday.
Any help/direction is much appreciated.
Thanks!
Ida
http://us2.php.net/manual/en/function.date.php
Course I skipped the minutes on purpose. I leave that to you.PHP Code:if ( (int)date( 'N' ) < 6 ) {
$h = (int)date( 'G' );
if ( $h >= 7 && $h <= 16 ) {
print 'Open!';
}
}

Just remember that if you are only open for a few hours each day that you will always appear to be closed to those people who are always asleep during those hours.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">




Don't forget holidays. It reflects badly if you say you are open during a holiday and you aren't.
MySQL v5.1.58
PHP v5.3.6





Just change your message to "We are probably open" and the holiday issue will be taken care of. Most of the time.

Holiday wont be an issue if he adds on the script what days his shop will be closed for say um the next year.
Thanks! Worked perfect.
Bookmarks