Show random number based on time of day

Hi I am trying to set up a script that will show a random number between 1 and 25 between the hours of 8.30 and 5.30 on a website.
The numbers have to increase as you go through the day.

For example if I go onto the site at 9am and see the number 4 then when I go onto the site at 3pm I wouldn’t be able to see anything less than 5.

Is this possible?

Any help would be much appreciated, thanks in advance.

How about outlining the exact rules of the algorithm first? Of course it’s possible, but what are the rules for number scaling?

Ok sorry if I wasn’t very clear to start with on this. This is what I need the script to do.

  1. Before 8.30 am show the word closed
  2. Between 8.30 am and 5.30 pm show a random number between 1 and 25 steadily increasing the nearer 5.30pm the time is.
  3. After 5.30 show a random number between 25 and 30

The main part I can’t work out would be how I make sure that the user doesn’t see a number less than they saw previously on the site. For example if they go onto the site at 10.30 am and see the number 5 then I don’t want them to go back onto the site at 2pm and see the number 4.

Does that make more sense?

Then go 1 step at a time :slight_smile:

I don’t think your outline is complete so I’ll go 1 point at a time.

  1. Pretty straight-forward, nothing to add here.

  2. What does “steadily” increasing mean exactly? You increase the number by the number of minutes left between current time and 5:30 or what? What’s the rule? You cannot tell the computer to “steadily” increase the numbers because computer doesn’t know what steadily is. You need some sort of interval here, based on either second / minute / hour / some other measurement unit valid for the given interval.

  3. Now this is a tricky one. You only have 5 integers to work with, unless you wanted to include floating point numbers.
    You are assuming that there’s a single point of failure here - seeing number 5 and then seeing number 4, which implies user connects twice.
    But the user might connect… 1000 times during that time period.
    You also need a way of tracking the user - either a login system (OpenID, Facebook one or your custom one) or you can attempt to track them by IP - either way, your logic imposes a certain way of being able to track the user.
    Once that system is in place, you can employ the logic on how to track numbers they saw.

As you can see, there’s quite a few variables here, until you clear them up - no way to move on :slight_smile: