Question:
How the best to convert $p=' "'.implode('","', $person).'"'; $p to an integer?
What I have:
I am trying to use an if statement telling $person == false;
$x['date']; is the timestamp in my database.
I have worked out the time difference, now I am trying to make the person disappear if post over 3 seconds.
so I used $t > 3 seconds then the $p == false;
The difficulty for my was the $t was implode so it a single string. I was trying to use preg_match, but I don't think this is a good idea.
I am trying to use $difference = settype($t, "integer"); but I am getting a boolean rather than a number.
$diff = array();
$person = array();
foreach($stmt as $x)
{
$person[] = $x['names']. $x['ages'];
$posts[] = $x['date'];
$timePosted = new DateTime($posts[] = $x['date']);
echo 'Time Posted : '. $timePosted ->format("d-m-Y H:i:s");
echo "</br>";
date_default_timezone_set('Europe/London');
$today = date('d-m-Y H:i:s');
echo 'Current time is : '. $today;
echo "</br>";
$today = new DateTime(date('d-m-Y H:i:s'));
$interval = $timePosted->diff($today);
"Difference " . $interval->d. " days ". $interval->h. " hours ".$interval->i." minutes ".$interval->s." seconds ";
echo "</br>";
$diff[] = $interval->h. " hours ".$interval->i." minutes ".$interval->s." seconds ";
$diff[] = $interval->s; //last array seconds
}
$p=' "'.implode('","', $person).'"';
echo $t= ' "'.implode('","', $diff).'"'."<br />";
$difference = settype($t, "integer");
echo gettype($difference);
echo "</br>";
if( $t >3){
$p == false;
}else{
echo "its okay, smaller than 3 seconds";
}
$p = intval($p), converts it to a proper integer? IF not, can you make your question shorter and concise.$t?