If this is not what you’re looking for, you’ll need to explain further.
/**
* prints a date/time based on a random timestamp from the last 24 hours
*
* @param int $t starting timestamp (defaults to "now")
* @param string $f date/time formatting string {@see php.net/date}
* @throws E_WARNING if no default timezone is set
* @return string a date/time string on success
*/
function random_datetime_last_day( $t=null,$f=null ){
$t = $t?: time();
$f = $f?: "Y-m-d H:i:s";
return date( $f,rand( ($t-(60*60*24)),$t ) );
}
// set timezone as desired
date_default_timezone_set('UTC');
// call function
echo random_datetime_last_day();