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();

 

你可能感兴趣的:(PHP)