note 104569 deleted from function.rand by danbrown

From: Date: Thu, 23 Jun 2011 14:37:16 +0000
Subject: note 104569 deleted from function.rand by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180886@lists.php.net to get a copy of this message
Note Submitter: Oguz KONYA ---- Improving Hugo Scott's random date generator to random datetime generator: function makeRandomDateInclusive($startDate,$endDate){ $days = round((strtotime($endDate) - strtotime($startDate)) / (60 * 60 * 24)); $n = rand(0,$days); $H = rand(0,23); $i = rand(0,59); $s = rand(0,59); return date("Y-m-d H:i:s",strtotime("$startDate + $n days $H hours $i minutes $s seconds")); } Simple, but useful.

« previous php.notes (#180886) next »