I need to select a random date between two dates. One date is random and the other one is set. I also have a starting date that the random date is based on. If that sounds confusing, my code will hopefully clarify what I am trying to do:
$postedtweettime = "2016-06-17 00:00:00";
$newtimehour = rand(0, 24);
$newtimemin = rand(0, 60);
$timestart = date('Y-m-d G:i:s', strtotime($postedtweettime. " + 7 days " . $newtimehour . " hours " . $newtimemin . " minutes"));
$timeend = date('Y-m-d G:i:s', strtotime($postedtweettime. ' + 21 days 0 hours 0 minutes'));
$newtime = rand($timestart, $timeend);
$newtimeformat = date('Y-m-d G:i:s', $newtime);
Everything works except getting the $newtimeformat date. Right now, the only value being returned is 1969-12-31 18:33:36
Aucun commentaire:
Enregistrer un commentaire