/    Sign up×
Community /Pin to ProfileBookmark

Need help comparing current time to calendar

I want a simple PHP file to advertise store hours (9 to 5, Mon to Fri),
tell the current day, hour, time and compare the current with the open time schedule and tell if the store is open or not.
I have the first part – I am lost on comparing the times.
Obviously I am just learning PHP.

What I have is:
<p align=”center”><font size=”5″ color=”#800000″>
Welcome to our Technical Support Office</font><br><br>
<align=”center”><font size=”4″ color=”#800000″>
Our hours of operation are 8 hours a day Monday through Friday, between 9 AM and 5 PM.<br><br></font></p>

<?PHP
$today = date(‘l F d, Y’);
$time = date(‘h:i A’);

print “<p align=center><font size=4 color=#800000>”;
print ‘Today is ‘ . date(‘l F d, Y’) . ‘ and the time is ‘ . date(‘h:i A’) .’.<br><br>’;

$printclosed = print “Our office is currently closed.<br><br>”;
$printopen = print “Our office is currently open.</font>”;

?>

I want one of the last two print lines to print.

Thanks for any help.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 02.2005 — [code=php]
$day = date("w"); # 0: Sun, 6: Sat
$hour = date("G"); # 0-23
$status = ($day > 0 and $day < 6 and $hour >= 9 and $hour < 5) ? "open" : "closed";
echo "<p>Our office is currently $status</p>n";
[/code]
×

Success!

Help @David_Billings spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...