Cette méthode permet de formater un timestamp sous une forme affichable, par exemple :
Hier, 15h06
Le 15.02.2006, 09h54
function getGoodTime ($timestamp){
$day = date (" d " ,$timestamp);
$month = date (" m " ,$timestamp);
$year = date (" Y " ,$timestamp);
$actual_day = date (" d " );
$actual_month = date (" m " );
$actual_year = date (" Y " );
if ($day = = $actual_day & & $month = = $actual_month & & $year = = $actual_year){
$first = " Aujourd'hui, " ;
} else if ($day = = ($actual_day - 1 ) & & $month = = $actual_month & & $year = = $actual_year){
$first = " Hier, " ;
} else {
$first = " Le " . $day . " / " . $month . " / " . $year . " , " ;
}
return ($first . date (" H " ,$timestamp) . " h " . date (" i " ,$timestamp));
}
|
|