Try making use of a timestamp via the strtotime. You'll have to do the
math, but you can generate a random number with the range being the
number of seconds in the date range and then adding the remaining
offset. Then convert the timestamp back to a date with everyones
favorite date() function.
Andy wrote:
> hi there,
>
> I am wondering if there is an easy way to generate a random date. It would
> work by creating arrays of values and then just selecting like:
>
> $year = array(2002, 2003, 2004, 2005);
> $month = array
> ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Okt','Nov','Dez');
>
> $date = $month[rand(0,count($month))].' '.rand(0,31).',
> '.$year[rand(0,count($year))];
>
> But there might be an easyer and faster (better performant) way.
>
> Thanx for any help,
>
> Andy
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php