我需要从今天获得随机时间。我试过用这个使用今天的日期获取随机时间
$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) –