Ejemplo n.º 1
0
 /**
  * Calculates a difference between two dates.
  * @return string Something like this: 1 year. 2 mon. 6 day. 4 hours. 21 min. 10 sec.
  */
 public static function date_period_text($date_start, $date_finish)
 {
     $result = Daemon::date_period($date_start, $date_finish);
     $str = '';
     if ($result[5] > 0) {
         $str .= $result[5] . ' year. ';
     }
     if ($result[4] > 0) {
         $str .= $result[4] . ' mon. ';
     }
     if ($result[3] > 0) {
         $str .= $result[3] . ' day. ';
     }
     if ($result[2] > 0) {
         $str .= $result[2] . ' hour. ';
     }
     if ($result[1] > 0) {
         $str .= $result[1] . ' min. ';
     }
     if ($result[0] > 0 || $str == '') {
         $str .= $result[0] . ' sec. ';
     }
     return rtrim($str);
 }