Make WordPress Core


Ignore:
Timestamp:
12/19/2004 12:10:10 AM (20 years ago)
Author:
saxmatt
Message:

First pass at dashboard. Hat tip: Jesuit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-formatting.php

    r1964 r1976  
    551551}
    552552
     553function human_time_diff( $from, $to = '' ) {     
     554    if ( empty($to) )
     555        $to = time();
     556    $diff = (int) ($to - $from);
     557    if ($diff <= 3600) {
     558        $mins = round($diff / 60);
     559        $since = sprintf( __('%s mins', $mins) );
     560    } else if (($diff <= 86400) && ($diff > 3600)) {
     561        $hours = round($diff / 3600);
     562        if ($hours <= 1)
     563            $since = __('1 hour');
     564        else
     565            $since = sprintf( __('%s hours'), $hours );
     566    } elseif ($diff >= 86400) {
     567        $days = round($diff / 86400);
     568        if ($days <= 1)
     569            $since = __('1 day');
     570        else
     571            $since = sprintf( __('%s days'), $days );
     572    }
     573    return $since;
     574}
     575
    553576?>
Note: See TracChangeset for help on using the changeset viewer.