ReportsGenerator::timeSpent( $activity )

Format secons to human readable teim spent

Description

Source

File: bp-integrations/learndash/library/ReportsGenerator.php

	protected function timeSpent($activity)
	{
		$seconds = intval($activity->activity_time_spent);

		if ($seconds < 60) {
			return sprintf('%ds', $seconds);
		}

		$minutes = floor($seconds/60);
		$seconds = $seconds % 60;

		if ($minutes < 60) {
			return sprintf(
				'%d%s',
				$minutes,
				_n('min', 'mins', $minutes, 'buddyboss')
			);
		}

		$hours = floor($minutes / 60 * 10) / 10;

		if ($hours < 24) {
			return sprintf(
				'%d %s',
				$hours,
				_n('hr', 'hrs', $hours, 'buddyboss')
			);
		}
	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.