I have a notification button where it shows the last requests that will come out on the system, I wanted to add the time it already left. Ex: 4 minutes ago, 1 hour ago, and when it was over 24 hours it showed 1 day ago, 2 days ago ..... I tried in several ways to shorten the times, but it can not. In my database I keep the following data:
record_date - > the day it was registered Ex: 2017-05-18;
schedule_register-> the time it was registered Eg: 10:19:30
function tempoCorridoDois($dataHoraString2) {
$hoje2 = strtotime(date('Y/m/d H:i:s'));
$dataHora2 = strtotime($dataHoraString2);
$diferenca2 = $hoje2 - $dataHora2;
$segundos2 = $diferenca2;
$minutos2 = round($diferenca2 / 60);
$horas2 = round($diferenca2 / 3600);
$dias2 = round($diferenca2 / 86400);
$semanas2 = round($diferenca2 / 604800);
$meses2 = round($diferenca2 / 2419200);
$anos2 = round($diferenca2 / 29030400);
if ($segundos2 <= 60) {
return "1 minuto atrás.";
}else if ($minutos2 <= 60) {
return $minutos2 . ' minutos atrás.';
}else if ($horas2 <= 24) {
return $horas2 . ' horas atrás.';
}else if ($dias2 <= 7) {
return $dias2 . ' dia(s) atrás.';
}else if ($semanas2 <= 4) {
return $semanas2 . ' semanas atrás.';
}else if ($meses2 <= 12) {
return $meses2 . ' meses atrás.';
}else{
return $anos2 . ' anos atrás.';
}
}
$tempoFinal2 = tempoCorridoDois($dataregistro2.$horarioregistro2);
And the following error appears: Fatal error: Can not redeclare tiempoCorridoDois () (in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notification 136