Exemplo n.º 1
0
function countdown($time)
{
    $updated = stripinput($time);
    $second = 1;
    $minute = $second * 60;
    $hour = $minute * 60;
    // microseconds
    $day = 24 * $hour;
    $month = days_current_month() * $day;
    $year = date("L", $updated) > 0 ? 366 * $day : 365 * $day;
    $timer = array($year => "year", $month => "month", $day => "day", $hour => "hour", $minute => "minute", $second => "second");
    foreach ($timer as $arr => $unit) {
        $calc = $updated / $arr;
        // balance timestamp
        if ($calc >= 1) {
            $answer = round($calc);
            $s = $answer > 1 ? "s" : "";
            return "<abbr class='atooltip' data-toggle='tooltip' data-placement='top' title='~" . showdate('newsdate', $updated + time()) . "'>{$answer} " . $unit . $s . "</abbr>";
        }
    }
    if (!isset($answer)) {
        return "<abbr class='atooltip' data-toggle='tooltip' data-placement='top' title='" . showdate('newsdate', time()) . "'>now</abbr>";
    }
}
 function countdown($time)
 {
     global $locale;
     $updated = stripinput($time);
     $second = 1;
     $minute = $second * 60;
     $hour = $minute * 60;
     $day = 24 * $hour;
     $month = days_current_month() * $day;
     $year = date("L", $updated) > 0 ? 366 * $day : 365 * $day;
     $timer = array($year => $locale['year'], $month => $locale['month'], $day => $locale['day'], $hour => $locale['hour'], $minute => $locale['minute'], $second => $locale['second']);
     $timer_b = array($year => $locale['year_a'], $month => $locale['month_a'], $day => $locale['day_a'], $hour => $locale['hour_a'], $minute => $locale['minute_a'], $second => $locale['second_a']);
     foreach ($timer as $arr => $unit) {
         $calc = $updated / $arr;
         if ($calc >= 1) {
             $answer = round($calc);
             $string = $answer > 1 ? $timer_b[$arr] : $unit;
             return "<abbr class='atooltip' data-toggle='tooltip' data-placement='top' title='~" . showdate('newsdate', $updated + time()) . "'>{$answer} " . $string . "</abbr>";
         }
     }
     if (!isset($answer)) {
         return "<abbr class='atooltip' data-toggle='tooltip' data-placement='top' title='" . showdate('newsdate', time()) . "'>now</abbr>";
     }
 }