我怎样才能在过去生成一个随机日期?

use*_*659 2 php date

使用PHP.

它必须是有效的,如:

2001-6-28 14:20:29

(如果可能的话,不超过10年)

Tho*_*nes 5

unix timestamp是一个从0到n的整数,所以你可以在php中使用普通的随机方法:)

$timestamp = rand(0, time() - 60*60*24*365*10);

// Prints something like: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A', $timestamp);
Run Code Online (Sandbox Code Playgroud)