public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/frontend/functions.php
/**
 * Get the time difference using days, hours and minutes.
 *
 * @since 1.0.0
 *
 * @param integer $futureTime The timestamp of a time in the future.
 *
 * @return string The human time in days, hours and minutes.
 */
Get the time difference using days, hours and minutes.

@param integer $futureTime The timestamp of a time in the future.

@return string The human time in days, hours and minutes.
Get the time difference using days hours and minutes . @param integer $futureTime The timestamp of a time in the future . @return string The human time in days hours and minutes .
function WPCW_date_getHumanTimeDiff( $futureTime ) {
	$humanTime = false;
	$secondsLeft = $futureTime - current_time( 'timestamp' );
	$days        = floor( $secondsLeft / 86400 );
	$secondsLeft = $secondsLeft - ( $days * 86400 );
	$hours       = floor( $secondsLeft / 3600 );
	$secondsLeft = $secondsLeft - ( $hours * 3600 );
	$minutes     = floor( $secondsLeft / 60 );
	$secondsLeft = $secondsLeft - ( $minutes * 60 );
	if ( $minutes > 0 ) {
		$humanTime = sprintf( _n( '%d minute', '%d minutes', $minutes, 'wp-courseware' ), $minutes );
		if ( $days > 0 || $hours > 0 ) {
			$humanTime = sprintf( _n( '%d hour', '%d hours', $hours, 'wp-courseware' ), $hours )
			             . ' ' . _x( 'and', 'Used in context of 4 days 7 hours and 14 minutes', 'wp-courseware' ) . ' ' . $humanTime;
			if ( $days > 0 ) {
				$humanTime = sprintf( _n( '%d day', '%d days', $days, 'wp-courseware' ), $days ) . ' ' . $humanTime;
			}
		}
	} else { 
		$humanTime = sprintf( _n( '%d second', '%d seconds', $secondsLeft, 'wp-courseware' ), $secondsLeft );
	}
	return $humanTime;
}
function WPCW_date_getHumanTimeDiff ( $ futureTime ) { $ humanTime = false ; $ secondsLeft = $ futureTime - current_time ( 'timestamp' ) ; $ days = floor ( $ secondsLeft / 86400 ) ; $ secondsLeft = $ secondsLeft - ( $ days * 86400 ) ; $ hours = floor ( $ secondsLeft / 3600 ) ; $ secondsLeft = $ secondsLeft - ( $ hours * 3600 ) ; $ minutes = floor ( $ secondsLeft / 60 ) ; $ secondsLeft = $ secondsLeft - ( $ minutes * 60 ) ; if ( $ minutes > 0 ) { $ humanTime = sprintf ( _n ( '%d minute' , '%d minutes' , $ minutes , 'wp-courseware' ) , $ minutes ) ; if ( $ days > 0 || $ hours > 0 ) { $ humanTime = sprintf ( _n ( '%d hour' , '%d hours' , $ hours , 'wp-courseware' ) , $ hours ) . ' ' . _x ( 'and' , 'Used in context of 4 days 7 hours and 14 minutes' , 'wp-courseware' ) . ' ' . $ humanTime ; if ( $ days > 0 ) { $ humanTime = sprintf ( _n ( '%d day' , '%d days' , $ days , 'wp-courseware' ) , $ days ) . ' ' . $ humanTime ; } } } else { $ humanTime = sprintf ( _n ( '%d second' , '%d seconds' , $ secondsLeft , 'wp-courseware' ) , $ secondsLeft ) ; } return $ humanTime ; }
Get the time difference using days, hours and minutes.
Get the time difference using days hours and minutes .
// Work out seconds between now and future time. // Now create a time based on what we've got. // Must add hours, because we've got days // Now add days // Less than 1 minute remaining...