# Pastebin diNbHNcw function format_interval($from, $to) { try { $from_obj = $from instanceof DateTime ? $from : new DateTime($from); $to_obj = $to instanceof DateTime ? $to : new DateTime($to); $diff = $to_obj->diff($from_obj); $times = []; if ($diff->y) { $times[] = [$diff->y, 'year']; if ($diff->m) { $times[] = [$diff->m, 'month']; } } elseif ($diff->m) { $times[] = [$diff->m, 'month']; } elseif ($diff->d) { $times[] = [$diff->d, 'day']; } else { $eolPeriod = 'midnight'; } if ($times) { $eolPeriod = implode(', ', array_map( function ($t) { return "$t[0] $t[1]" . ($t[0] != 1 ? 's' : ''); }, $times ) ); if ($diff->invert) { $eolPeriod = "$eolPeriod ago"; } else { $eolPeriod = "in $eolPeriod"; } } } catch (Exception $e) { $eolPeriod = 'unknown'; } return $eolPeriod; }