src/Duration.php
public function humanize($duration = null)
    {
        if (null !== $duration) {
            $this->parse($duration);
        }

        if ($this->seconds > 0 || ($this->seconds === 0.0 && $this->minutes === 0 && $this->hours === 0 && $this->days === 0)) {
            $this->output .= $this->seconds . 's';
        }

        if ($this->minutes > 0) {
            $this->output = $this->minutes . 'm ' . $this->output;
        }

        if ($this->hours > 0) {
            $this->output = $this->hours . 'h ' . $this->output;
        }

        if ($this->days > 0) {
            $this->output = $this->days . 'd ' . $this->output;
        }

        return trim($this->output());
    }
public function humanize($duration = null)
    {
        if (null !== $duration) {
            $this->parse($duration);
        }

        if ($this->seconds > 0 || ($this->seconds === 0.0 && $this->minutes === 0 && $this->hours === 0 && $this->days === 0)) {
            $this->output .= $this->seconds . 's';
        }

        if ($this->minutes > 0) {
            $this->output = $this->minutes . 'm ' . $this->output;
        }

        if ($this->hours > 0) {
            $this->output = $this->hours . 'h ' . $this->output;
        }

        if ($this->days > 0) {
            $this->output = $this->days . 'd ' . $this->output;
        }

        return trim($this->output());
    }
public function humanize ( $ duration = null ) { if ( null !== $ duration ) { $ this -> parse ( $ duration ) ; } if ( $ this -> seconds > 0 || ( $ this -> seconds === 0.0 && $ this -> minutes === 0 && $ this -> hours === 0 && $ this -> days === 0 ) ) { $ this -> output .= $ this -> seconds . 's' ; } if ( $ this -> minutes > 0 ) { $ this -> output = $ this -> minutes . 'm ' . $ this -> output ; } if ( $ this -> hours > 0 ) { $ this -> output = $ this -> hours . 'h ' . $ this -> output ; } if ( $ this -> days > 0 ) { $ this -> output = $ this -> days . 'd ' . $ this -> output ; } return trim ( $ this -> output ( ) ) ; }
Returns the duration as a human-readable string.

For example, one hour and 42 minutes would be "1h 42m"

@param  int|float|string $duration A string or number, representing a duration
@return string
Returns the duration as a human - readable string .