Support » Fixing WordPress » How to change the human-time-diff post-date language?

Viewing 2 replies - 1 through 2 (of 2 total)
  • That function is located in

    wp-includes/formatting.php

    around line 2101, and looks like it’s hard coded into the code as you can see after %s

    function human_time_diff( $from, $to = '' ) {
            if ( empty( $to ) )
                    $to = time();
            $diff = (int) abs( $to - $from );
            if ( $diff <= HOUR_IN_SECONDS ) {
                    $mins = round( $diff / MINUTE_IN_SECONDS );
                    if ( $mins <= 1 ) {
                            $mins = 1;
                    }
                    /* translators: min=minute */
                    $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
            } elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) {
                    $hours = round( $diff / HOUR_IN_SECONDS );
                    if ( $hours <= 1 ) {
                            $hours = 1;
                    }
                    $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
            } elseif ( $diff >= DAY_IN_SECONDS ) {
                    $days = round( $diff / DAY_IN_SECONDS );
                    if ( $days <= 1 ) {
                            $days = 1;
                    }
                    $since = sprintf( _n( '%s day', '%s days', $days ), $days );
            }
            return $since;
    }

    So you have to manually edit this file.

    Henry

    (@henrywright-1)

    you could copy the function to your theme’s functions.php file, rename it and then change the language. That’s what i did.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change the human-time-diff post-date language?’ is closed to new replies.