0
I’m trying to make an algorithm that divides the value of the function strtotime
and aired in minutes, hours. And now I’m trying to put in days, created the variable $datadia
, but I’m unable to display if the value is above 24 hours
The result is only displayed in minutes and then hours if it is above 60 minutes.
$phpdate = strtotime( $data );
$mysqldate = date( 'd-m-Y H:i:s', $phpdate );
$data1 = strtotime($mysqldate);
$data2 = strtotime("now");
$data3 = (int)(-($data1 - $data2)/60);
$data4 = (int)(($data3)/60);
$datadia = (int)(($data4)/24);
if (!empty($data) and $data3<=60){
echo "Chegou $mysqldate<br>há $data3 minutos atrás<br>";
}
elseif (!empty($data)) {
echo "Chegou $mysqldate <br>há $data4 horas atrás<br>";
}
elseif (!empty($data)) {
echo "Chegou $mysqldate <br>há $datadia dias atrás<br>";
}
The problem would not be to be using variables of type
int
? Beingx < 60
the result ofx / 60
shall be less than 1. Inint
that would be a 0.– Ronaldo Araújo Alves