...

View Full Version : Resolved Shops open/closed



[vengeance]
09-07-2009, 11:23 PM
Hey.

I have a market with different shops, where people can buy stuff at. But I want to make it more realistic, so the shop opens at 7 AM in the morning and closes at 9:59 PM.

I tried playing around with the date(); function but couldn't get it to work. Can anyone help me to check if the time is between 7:00 AM and 9:59 PM?
( date("G:i"); )

Thanks

Zangeel
09-07-2009, 11:50 PM
<?php

if (date("G") > 8 && date("G") < 22)
{
echo 'We\'re open for binness';
} else {

die ( 'We Closed :(' );
}
?>


"G" is the 24 hour time stamp for the hour interval. So the above code makes sure it's greater than 8 o clock but less than 10 o clock.

[vengeance]
09-08-2009, 12:15 AM
<?php

if (date("G") > 8 && date("G") < 22)
{
echo 'We\'re open for binness';
} else {

die ( 'We Closed :(' );
}
?>


"G" is the 24 hour time stamp for the hour interval. So the above code makes sure it's greater than 8 o clock but less than 10 o clock.
Oh damn. I'm horrible at those "greater than" and "less than".

I played around with


date("Gi") > 700

etc. No wonder why it didn't work, lol. Thanks for your help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum