private static function interval( $since ) {
		if ( $since <= 0 ) {
			return 'now';
		}

		$since = absint( $since );

		// array of time period chunks
		$chunks = array(
			array( 60 * 60 * 24 * 365, 'year' ),
			array( 60 * 60 * 24 * 30, 'month' ),
			array( 60 * 60 * 24 * 7, 'week' ),
			array( 60 * 60 * 24, 'day' ),
			array( 60 * 60, 'hour' ),
			array( 60, 'minute' ),
			array( 1, 'second' ),
		);

		// we only want to output two chunks of time here, eg:
		// x years, xx months
		// x days, xx hours
		// so there's only two bits of calculation below:

		// step one: the first chunk
		for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
			$seconds = $chunks[ $i ][0];
			$name    = $chunks[ $i ][1];

			// finding the biggest chunk (if the chunk fits, break)
			$count = floor( $since / $seconds );
			if ( floatval( 0 ) !== $count ) {
				break;
			}
		}

		// set output var
		$output = sprintf( '%d %s', $count, Utils\pluralize( $name, absint( $count ) ) );

		// step two: the second chunk
		if ( $i + 1 < $j ) {
			$seconds2 = $chunks[ $i + 1 ][0];
			$name2    = $chunks[ $i + 1 ][1];

			$count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
			if ( floatval( 0 ) !== $count2 ) {
				// add to output var
				$output .= ' ' . sprintf( '%d %s', $count2, Utils\pluralize( $name2, absint( $count2 ) ) );
			}
		}

		return $output;
	}
private static function interval( $since ) {
		if ( $since <= 0 ) {
			return 'now';
		}

		$since = absint( $since );

		// array of time period chunks
		$chunks = array(
			array( 60 * 60 * 24 * 365, 'year' ),
			array( 60 * 60 * 24 * 30, 'month' ),
			array( 60 * 60 * 24 * 7, 'week' ),
			array( 60 * 60 * 24, 'day' ),
			array( 60 * 60, 'hour' ),
			array( 60, 'minute' ),
			array( 1, 'second' ),
		);

		// we only want to output two chunks of time here, eg:
		// x years, xx months
		// x days, xx hours
		// so there's only two bits of calculation below:

		// step one: the first chunk
		for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
			$seconds = $chunks[ $i ][0];
			$name    = $chunks[ $i ][1];

			// finding the biggest chunk (if the chunk fits, break)
			$count = floor( $since / $seconds );
			if ( floatval( 0 ) !== $count ) {
				break;
			}
		}

		// set output var
		$output = sprintf( '%d %s', $count, Utils\pluralize( $name, absint( $count ) ) );

		// step two: the second chunk
		if ( $i + 1 < $j ) {
			$seconds2 = $chunks[ $i + 1 ][0];
			$name2    = $chunks[ $i + 1 ][1];

			$count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
			if ( floatval( 0 ) !== $count2 ) {
				// add to output var
				$output .= ' ' . sprintf( '%d %s', $count2, Utils\pluralize( $name2, absint( $count2 ) ) );
			}
		}

		return $output;
	}
private static function interval ( $ since ) { if ( $ since <= 0 ) { return 'now' ; } $ since = absint ( $ since ) ; // array of time period chunks $ chunks = array ( array ( 60 * 60 * 24 * 365 , 'year' ) , array ( 60 * 60 * 24 * 30 , 'month' ) , array ( 60 * 60 * 24 * 7 , 'week' ) , array ( 60 * 60 * 24 , 'day' ) , array ( 60 * 60 , 'hour' ) , array ( 60 , 'minute' ) , array ( 1 , 'second' ) , ) ; // we only want to output two chunks of time here, eg: // x years, xx months // x days, xx hours // so there's only two bits of calculation below: // step one: the first chunk for ( $ i = 0 , $ j = count ( $ chunks ) ; $ i < $ j ; $ i ++ ) { $ seconds = $ chunks [ $ i ] [ 0 ] ; $ name = $ chunks [ $ i ] [ 1 ] ; // finding the biggest chunk (if the chunk fits, break) $ count = floor ( $ since / $ seconds ) ; if ( floatval ( 0 ) !== $ count ) { break ; } } // set output var $ output = sprintf ( '%d %s' , $ count , Utils \ pluralize ( $ name , absint ( $ count ) ) ) ; // step two: the second chunk if ( $ i + 1 < $ j ) { $ seconds2 = $ chunks [ $ i + 1 ] [ 0 ] ; $ name2 = $ chunks [ $ i + 1 ] [ 1 ] ; $ count2 = floor ( ( $ since - ( $ seconds * $ count ) ) / $ seconds2 ) ; if ( floatval ( 0 ) !== $ count2 ) { // add to output var $ output .= ' ' . sprintf ( '%d %s' , $ count2 , Utils \ pluralize ( $ name2 , absint ( $ count2 ) ) ) ; } } return $ output ; }
Converts a time interval into human-readable format.

Similar to WordPress' built-in `human_time_diff()` but returns two time period chunks instead of just one.

@param int $since An interval of time in seconds
@return string The interval in human readable format
Converts a time interval into human - readable format .