PHP生成随机日期

I want a php script that generates random time:

For eg

first time : 2014-02-14 10:21:02 next time : 2014-02-14 08:21:02

only time changes date doesnot change.

You could do it with mt_rand() like this:

echo date('Y-m-d')." ".mt_rand(0, 23).":".mt_rand(0, 59).":".mt_rand(0, 59);
$first_date = "2014-02-14 10:21:02";
$second_date = "2014-02-14 08:21:02";

$first_time = strtotime($first_date);
$second_time = strtotime($second_date);

$rand_time = rand($first_time, $second_time);
$rand_date = date('Y-m-d g:i:s', $rand_time);

echo $rand_date;

DEMO

UPDATE: today's random date

$first_time = strtotime(date('Y-m-d'));
$second_time = $first_time+86400;

$rand_time = rand($first_time, $second_time);
$rand_date = date('Y-m-d g:i:s A', $rand_time);

echo $rand_date;

DEMO

You can use rand for this purpose

$int= rand(1262055681,1262055681);

You can use mt_rand too

$int= mt_rand(1262055681,1262055681); which provides better randomness in the results

See here for the reference