Convert a value from pure minutes into something easily digestible.

@param $minutes

@return string
186387
protected function convertFromMinutes($minutes)
    {
        $seconds = $minutes * 60;

        $secondsInAMinute = 60;
        $secondsInAnHour  = 60 * $secondsInAMinute;
        $secondsInADay    = 24 * $secondsInAnHour;

        // extract days
        $days = floor($seconds / $secondsInADay);

        // extract hours
        $hourSeconds = $seconds % $secondsInADay;
        $hours       = floor($hourSeconds / $secondsInAnHour);

        // extract minutes
        $minuteSeconds = $hourSeconds % $secondsInAnHour;
        $minutes       = floor($minuteSeconds / $secondsInAMinute);

        // return the final string
        $output = '';

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

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

        $output .= $minutes . ' ' . $this->pluralize('minute', $minutes);

        return $output;
    }
291549
function minutesToOffsetString(minutes) {
  var t = String(Math.abs(minutes / 60)).split('.');
  var H = pad(t[0]);
  var m = t[1] ? parseInt(t[1], 10) * 0.6 : 0;
  var sign = minutes < 0 ? '-' : '+';

  return '' + sign + H + ':' + pad(m);
}
787076
public static function formatStrTime($time, $withSeconds = true)
    {
        // Pad left with 0 in case we get numbers like 123, 12, 122015
        $time = str_pad($time.'', 6, '0', STR_PAD_LEFT);

        $_time = array();

        $_time[] = substr($time, 0, 2);
        $_time[] = substr($time, 2, 2);

        if ($withSeconds) {
            $_seconds = substr($time, 4, 2);
            $_time[] = $_seconds;
        }

        return implode(':', $_time);
    }
1363747
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());
    }
811002
public static function formatSeconds($seconds)
    {
        $format = '';
        $rest = $seconds;
        if ($seconds >= 86400) {
            $format .= floor($seconds/86400).'d ';
            $rest = $seconds%86400;
        }

        if ($rest >= 3600) {
            $format .= floor($rest/3600).'h ';
            $rest = $rest%3600;
        }

        if ($rest >= 60) {
            $format .= floor($rest/60) . 'min ';
            $rest = $rest%60;
        }

        if ($rest > 0) {
            $format .= $rest . 'sec ';
        }

        return trim($format);
    }
499840
protected function normalizeDateValue($time)
	{
		if(is_string($time))
		{
			if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
				return (int)$time;
			else
				return strtotime($time);
		}
		elseif (class_exists('DateTime', false) && $time instanceof DateTime)
			return $time->getTimestamp();
		else
			return (int)$time;
	}
997565
protected static function get_duration_text($seconds) {
        if (empty($seconds)) {
            return get_string('none');
        }
        $data = self::parse_seconds($seconds);
        switch ($data['u']) {
            case (60*60*24*7):
                return get_string('numweeks', '', $data['v']);
            case (60*60*24):
                return get_string('numdays', '', $data['v']);
            case (60*60):
                return get_string('numhours', '', $data['v']);
            case (60):
                return get_string('numminutes', '', $data['v']);
            default:
                return get_string('numseconds', '', $data['v']*$data['u']);
        }
    }
1236007
public function longFormat($duration)
	{
		if( isset($duration) ) $this->__construct($duration);
		if( $this->hoursSection >= 1 )
		{
			return sprintf(
				' %s ' . str_plural('hour', $this->hoursSection) .
				' %s ' . str_plural('minute', $this->minutesSection) .
				' %s ' . str_plural('second', $this->secondsSection)
				, $this->hoursSection, $this->minutesSection, $this->secondsSection);
		}
		if( $this->minutesSection >= 1 && $this->secondsSection )
		{
			return sprintf(
				' %s ' . str_plural('minute', $this->minutesSection) .
				' %s ' . str_plural('second', $this->secondsSection)
				, $this->minutesSection, $this->secondsSection);
		}
		if( $this->minutesSection >= 1 )
		{
			return sprintf(
				' %s ' . str_plural('minute', $this->minutesSection)
				, $this->minutesSection);
		}


		return sprintf(' %s ' . str_plural('second', $this->secondsSection), $this->secondsSection);
	}
512967
public function humanReadingTime($content)
    {
        if (empty($content)) {
            return '';
        }
        $content = StringHelper::stripHtml($content);
        $seconds = $this->readingTime($content);

        return Craft::$app->formatter->asDuration($seconds);
    }
955160
public static function prettySeconds( $seconds = 0.0 )
    {
        $_remain = $seconds;
        $_hours = floor( $_remain / Enums\DateTime::SecondsPerHour );
        $_remain -= $_hours * Enums\DateTime::SecondsPerHour;

        $_minutes = floor( $_remain / Enums\DateTime::SecondsPerMinute );
        $_remain -= $_minutes * Enums\DateTime::SecondsPerMinute;

        return $_hours . 'h ' . $_minutes . 'm ' . number_format( $_remain, 2 ) . 's';
    }
354670
public static function niceDuration($value, array $options = []) : string {
		if (empty($value)) return '';
		if ($value < 60) {
			return self::id($value) . ' ' . i18n(null, 'seconds');
		} else if ($value < 360) {
			return self::id(round($value / 60, 2)) . ' ' . i18n(null, 'minutes');
		} else {
			return self::id(round($value / 360, 2)) . ' ' . i18n(null, 'hours');
		}
	}
675388
public static function format($time): string
    {
        $time = round($time * 1000);
        foreach (self::$times as $unit => $value) {
            if ($time >= $value) {
                $time = floor($time / $value * 100.0) / 100.0;
                return $time . ' ' . $unit . ((float)$time === 1.0 ? '' : 's');
            }
        }

        return $time . ' ms';
    }
241889
function formatTime($seconds) {
		switch (true) {
			case $seconds == 0:
				return 0;
			
			case $seconds < 0.01:
				$time = round($seconds * 1000, 2) . 'ms';
				break;
			
			case $seconds < 0.1:
				$time = round($seconds * 1000, 1) . 'ms';
				break;
			
			case $seconds < 1:
				$time = round($seconds * 1000) . 'ms';
				break;
			
			case $seconds < 10:
				$time = round($seconds, 2) . 's';
				break;
			
			default:
				$time = round($seconds, 1) . 's';
		}
		
		return $time;
	}
883952
private function colorizeMminute($minute = '', array $colors = [])
    {
        $cleanedColors = array_filter($colors);

        if (empty($cleanedColors)) {
            return $minute;
        }

        return sprintf('<span class="block-color" style="background-color: %s">%s</span>', current($cleanedColors), $minute);
    }
163027
public function duration($seconds)
    {
        $result = [
            'hour'     => (int) floor($seconds / 3600),
            'min'      => (int) floor(($seconds / 60) % 60),
            'sec'      => $seconds % 60,
            'ms'       => (int) round(\fmod($seconds, 1) * 1000),
        ];

        $duration = '';
        foreach ($result as $unit => $value) {
            if (!empty($value) || $unit === 'ms') {
                $duration .= $value . "$unit ";
            }
        }

        $result['duration'] = trim($duration);

        return $result;
    }
1348625
protected function integerToString($time): string
    {
        $tokens = array_reverse($this->tokensValues, true);
        $expression = [];

        foreach ($tokens as $token => $value) {
            if ($time <= 0) {
                break;
            }
            if ($time < $value || !in_array($token, array_keys($this->tokensValues))) {
                continue;
            }
            $mod = 0;
            if ($time & $value) {
                $mod = fmod($time, $value);
                $time -= $mod;
            }
            $div = round($time / $value);

            $expression[] = sprintf(
                '%d %s',
                $div,
                ($token.(($div > 1 && substr($token, -1, 1) !== 's') ? 's' : ''))
            );
            $time = $mod;
        }

        $return = implode(' ', $expression);
        if (empty($return)) {
            $return = sprintf('%d %s', 0, 'ms');
        }

        return $return;
    }
167303
static public function timestamp($value)
    {
        $value || $value = time();
        if(is_numeric($value)) {
            //$value = strftime('%Y-%m-%d %H:%M:%S', $value);
            $value = strftime('%Y-%m-%d %H:%M:%S', $value);
        }
        
        return $value;
    }