Okay, so I have a chat feature on my website that I’ve mentioned in other questions. There are some kids at my school who would love to chat during school, but I’d really rather they’d just chat during study hall so I don’t get in trouble for interrupting class time. How can I restrict user movement on my website during specific time periods during the day? Thanks! I don’t know what type of scripting language I might need for this, but I’m assuming PHP since this is a server issue.
Share
returns the current hour in a 24 hour format with leading zeroes.
That means, you can write something like this:
This will “die” echoing the page, and will return the error instead, exactly during the 14th hour of the day (2:00 pm).
Give us more code/details to get a deeper answer.
EDIT: This is an expanded answer to the new question, asking,
SOLUTION: Assuming study hall is the time when the students are allowed to use the (section of) the site, you would do something like this:
To explain how this works: your time base is counted into minutes as
$bottomValueand$upperValue. Notice how they are defined, it’s 60 minutes multiplied by hour (14) plus minutes (30).So, 14:30 is
60*14+30, therefore, 16:20 would be60*16+20.Then the base is compared to the current time and an appropriate code is executed according to the if/else statements.