Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Do Something At Random times Every Day?

Asked Modified Viewed 2,061 times
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
  • Started this discussions
asked
Fusioneer

Hi,

PHP, How do I Do Something At Random times Every Day? Lets say I want to do something every day but I want it to be done at 1 random time every 24 hours how would I go about that? How do I pick a random hour, and min?

Kind Regards
Craig
0 replies

3 posts

M
MeTRoiD
M
  • Member, joined since
  • Contributed 114 posts on the community forums.
  • Started 11 threads in the forums
answered
Member

I would do it like:
 $randomtime = $data[event_time]
 $seen = $data[event_seen]
if ( $randomtime == time() && $seen == "0") { // equal or more for time!!!!!!!
// works the the thing you want
// inserts in database time for next event with value $randomtime and updates as seen previous..
}

maybe $not_seen you don't need.. simply delete $randomtime and insert new.. or update..
p.s. google had some results for the random time function.. (with interval or limit)
0 replies
A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

Use rand!

$hours = rand(0,23);
$mins = rand(0,59);
$secs = rand(0,59);

And Then use date for comparison... :G
0 replies
P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

Don't forget to save dis date, mon, every day - new random time.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 3 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
  • Started this discussions
M
M
  • Member, joined since
  • Contributed 114 posts on the community forums.
  • Started 11 threads in the forums
P
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
A
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet