我需要從今天獲得隨機時間。我試過用這個使用今天的日期獲取隨機時間
$today = date('YmdHi');
$startDate = date('YmdHi', strtotime('-0.5 days'));
$range = $today - $startDate;
$rand = rand(0, $range);
$smthing=$startDate + $rand;
return $smthing;
但它不能正常工作。
例如,我想生成今天的日期和任何它。
預期輸出
2015:25:09 14點10分20秒
2015:25:09 8時12分26秒
2015:25:09 01:02 :24
爲什麼你不能只使用'time()'。畢竟它一直都在變化! :D – jitendrapurohit
@JitendraPurohit不錯的一個!笑笑 – RiggsFolly
這可能有助於[鏈接](http://stackoverflow.com/questions/1972712/generate-random-date-between-two-dates-using-php) –