PHP Eshop Closing Time Code Message
I was recently asked to code a little widget for someone’s Eshop to display a message at a certain time of day to say if they were open or closed.
The shop’s opening hours were 8:00am – 11:30am then 4:00pm – 10:00pm.
-
<?php
-
-
$open_AM =
mktime(8,
0,
0);
//Open 8:00AM
-
$close_AM =
mktime(11,
30,
0);
// Closing 11:30AM
-
$open_PM =
mktime(16,
0,
0);
// Open 4:00PM
-
$close_PM =
mktime(22,
0,
0);
// Close 10:00PM
-
$offset = 7200;
-
-
//Current Server Time
-
echo "Current server time: ";
-
-
-
if ($t >= $open_AM && $t <= $close_AM)
-
{
-
-
}
-
else if($t >= $open_PM && $t <= $close_PM)
-
{
-
-
}else{
-
-
}
-
-
//Plus 2 Hours
-
-
-
-
?>
I will now break this code down for you.
No related posts.
This entry was posted by
Jamz on 2 January, 2010 at 12:29 am, and is filled under
PHP. Follow any responses to this post through
RSS 2.0. You can
leave a response or
trackback from your own site.