Example #1
0
 function format_time($time)
 {
     if ($time == 0) {
         $time = 1;
     }
     // Evite le temps de lecture nul
     $periods = array('years' => 86400 * 365, 'months' => 86400 * 31, 'days' => 86400, 'hours' => 3600, 'minutes' => 60, 'secondes' => 1);
     $reading = array();
     foreach ($periods as $period => $duration) {
         if ($time >= $duration) {
             $nb = floor($time / $duration);
             $time -= $nb * $duration;
             $reading[] = $nb . ' ' . PostStats::periodl10n($period, $nb);
         }
     }
     return implode(', ', $reading);
 }