ReportsGenerator::timeSpent( $activity )

Format secons to human readable teim spent

Description

Source

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

470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
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.