RE: [PHP] how to generate a date between 1998 and today by random?

From: Date: Tue, 07 May 2002 13:20:15 +0000
Subject: RE: [PHP] how to generate a date between 1998 and today by random?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-96411@lists.php.net to get a copy of this message
haven't tried that: use mktime to get unixtimestamps of today and of the date between 1998. create a random number between these timestamps (the random function should be capable of it, or just code yourself a little function). convert the resulting timestamp to a date using the todate() function. I think that should work and it should be easy enough. mike > -----Original Message----- > From: andy [mailto:news.letters@gmx.de] > Sent: Tuesday, May 07, 2002 3:12 PM > To: php-general@lists.php.net > Subject: [PHP] how to generate a date between 1998 and today > by random? > > > 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 > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.330 / Virus Database: 184 - Release Date: 28.02.2002 > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.330 / Virus Database: 184 - Release Date: 28.02.2002

« previous php.general (#96411) next »