2 added 353 characters in body
source | link

There is no filter for output of that function. You can fork (copy/rename/edit) it or add wrapper that will replace strings in output like this:

function short_time_diff( $from, $to = '' ) {

    $diff = human_time_diff($from,$to);

    $replace = array(
        'hour'  => 'h',
        'hours' => 'h',
        'day'   => 'd',
        'days'  => 'd',
    );

    return strtr($diff,$replace);
}

PS afterthought - actually strings are localized so there is translation filter to use... But stuff to replace is to generic and that will risk breaking it elsewhere.

UPDATE

Since WP 4.0 there is a filter available for human_time_diff:

add_filter( 'human_time_diff', function($since, $diff, $from, $to) {

    $replace = array(
        'hour'  => 'h',
        'hours' => 'h',
        'day'   => 'd',
        'days'  => 'd',
    );

    return strtr($since, $replace);

}, 10, 4 );

There is no filter for output of that function. You can fork (copy/rename/edit) it or add wrapper that will replace strings in output like this:

function short_time_diff( $from, $to = '' ) {

    $diff = human_time_diff($from,$to);

    $replace = array(
        'hour' => 'h',
        'hours' => 'h',
        'day' => 'd',
        'days' => 'd',
    );

    return strtr($diff,$replace);
}

PS afterthought - actually strings are localized so there is translation filter to use... But stuff to replace is to generic and that will risk breaking it elsewhere.

There is no filter for output of that function. You can fork (copy/rename/edit) it or add wrapper that will replace strings in output like this:

function short_time_diff( $from, $to = '' ) {

    $diff = human_time_diff($from,$to);

    $replace = array(
        'hour'  => 'h',
        'hours' => 'h',
        'day'   => 'd',
        'days'  => 'd',
    );

    return strtr($diff,$replace);
}

PS afterthought - actually strings are localized so there is translation filter to use... But stuff to replace is to generic and that will risk breaking it elsewhere.

UPDATE

Since WP 4.0 there is a filter available for human_time_diff:

add_filter( 'human_time_diff', function($since, $diff, $from, $to) {

    $replace = array(
        'hour'  => 'h',
        'hours' => 'h',
        'day'   => 'd',
        'days'  => 'd',
    );

    return strtr($since, $replace);

}, 10, 4 );
1
source | link

There is no filter for output of that function. You can fork (copy/rename/edit) it or add wrapper that will replace strings in output like this:

function short_time_diff( $from, $to = '' ) {

    $diff = human_time_diff($from,$to);

    $replace = array(
        'hour' => 'h',
        'hours' => 'h',
        'day' => 'd',
        'days' => 'd',
    );

    return strtr($diff,$replace);
}

PS afterthought - actually strings are localized so there is translation filter to use... But stuff to replace is to generic and that will risk breaking it elsewhere.