note 104569 added to function.rand

From: Date: Thu, 23 Jun 2011 12:09:16 +0000
Subject: note 104569 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-180870@lists.php.net to get a copy of this message
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. ---- Server IP: 160.75.100.7 Probable Submitter: 88.231.153.111 ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- https://master.php.net/note/edit/104569 Del: integrated -- https://master.php.net/note/delete/104569/integrated Del: useless -- https://master.php.net/note/delete/104569/useless Del: bad code -- https://master.php.net/note/delete/104569/bad+code Del: spam -- https://master.php.net/note/delete/104569/spam Del: non-english -- https://master.php.net/note/delete/104569/non-english Del: in docs -- https://master.php.net/note/delete/104569/in+docs Del: other reasons-- https://master.php.net/note/delete/104569 Reject -- https://master.php.net/note/reject/104569 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180870) next »