19-04-2008, 06:33 PM
Bon eh bien pour relancer un peu le sujet, une fonction simple utilisée notamment sur Youtube je crois
Code PHP :
<?php
function FormateMyDate($date){
$NuDate = time() - $date;
if($NuDate >= 0){$Unite = "$NuDate Seconde";}
elseif($NuDate >= 60){$NuDate = $NuDate / 60; $NuDate = ceil($NuDate); $Unite = "$NuDate Minute";}
elseif($NuDate >= 3600){$NuDate = $NuDate / 3600; $NuDate = round($NuDate); $Unite = "$NuDate Heure";}
elseif($NuDate >= 86400){$NuDate = $NuDate / 86400; $NuDate = round($NuDate); $Unite = "$NuDate Jour";}
elseif($NuDate >= 604800){$NuDate = $NuDate / 604800; $NuDate = floor($NuDate); $Unite = "$NuDate Semaine";}
if($NuDate > 1){$FormatedDate = $Unite . "s";}
else{$FormatedDate = $Unite;}
return $FormatedDate;
}