lundi 16 mars 2015

How can I generate a random time per day with php?

I want to generate one random time within a 24 hour period using php. Here is what I have so far:



srand(mktime(0, 0, 0));
$time = rand( 0, time() );
echo date("H:i", $time);


It seemed to work at first but after a couple hours the time changed slightly. I got 16:41 first and then it jumped to 16:47 or something near that. Any help with this would be greatly appreciated.


Aucun commentaire:

Enregistrer un commentaire