Update existing post times to random times?

This is the part that is responsible for random date:

//* Generate a random date between January 1st, 2015 and now
$random_date = mt_rand( strtotime( '1 January 2015' ), time() );

So you need to change it. And if you want to randomize only the time part, then this is one way to achieve that:

$random_date = strtotime( date( 'Y-m-d 00:00:00', strtotime($post->post_date) ) ) + mt_rand(0, 24*60*60); 

This line will:

  • take the date of post
  • get only day part of it
  • concert it to time
  • add random number of seconds to it

So it will randomize the time of publication.