diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index 334806b9e0..757eb07103 100644
|
a
|
b
|
function human_time_diff( $from, $to = '' ) {
|
| 3620 | 3620 | |
| 3621 | 3621 | $diff = (int) abs( $to - $from ); |
| 3622 | 3622 | |
| 3623 | | if ( $diff < HOUR_IN_SECONDS ) { |
| | 3623 | if ( $diff < MINUTE_IN_SECONDS ) { |
| | 3624 | $secs = $diff; |
| | 3625 | if ( $secs <= 1 ) { |
| | 3626 | $secs = 1; |
| | 3627 | } |
| | 3628 | /* translators: Time difference between two dates, in seconds. %s: Number of seconds */ |
| | 3629 | $since = sprintf( _n( '%s second', '%s seconds', $secs ), $secs ); |
| | 3630 | } elseif ( $diff < HOUR_IN_SECONDS && $diff >= MINUTE_IN_SECONDS ) { |
| 3624 | 3631 | $mins = round( $diff / MINUTE_IN_SECONDS ); |
| 3625 | 3632 | if ( $mins <= 1 ) { |
| 3626 | 3633 | $mins = 1; |
diff --git a/tests/phpunit/tests/formatting/HumanTimeDiff.php b/tests/phpunit/tests/formatting/HumanTimeDiff.php
index da1ad2dcfc..473f5325d3 100644
|
a
|
b
|
class Tests_Formatting_HumanTimeDiff extends WP_UnitTestCase {
|
| 19 | 19 | // Data for test_human_time_diff. |
| 20 | 20 | function data_test_human_time_diff() { |
| 21 | 21 | return array( |
| | 22 | array( |
| | 23 | '37 seconds', |
| | 24 | new DateTime( '2016-01-01 12:00:37' ), |
| | 25 | 'Test a difference of 37 seconds.', |
| | 26 | ), |
| 22 | 27 | array( |
| 23 | 28 | '5 mins', |
| 24 | 29 | new DateTime( '2016-01-01 12:05:00' ), |