try
$rand(1,$round($calc(($ctime($date 11:59pm) - $ctime($date $time)) / 60),0) )
it generates a random number between 1 and $round.....