2321ewq 发表于 2014-8-13 09:56:33

php 随机显示据今天30天内的任意一天

function randomDate() {

    //echo date( "Y-m-d H:m:s", $newtime);
    //echo date("Y-m-d H:m:s", strtotime("+2 week 1 days 7 hours 5 seconds"));
    $begin = strtotime("now");
    $end = strtotime("+1 Month");
    $timestamp = rand($begin, $end);
    return date("Y-m-d H:i:s", $timestamp);
}
echo randomDate();
页: [1]
查看完整版本: php 随机显示据今天30天内的任意一天