rtmedia_migrate_formatseconds

To be used in migration in importing.

Description

(string) rtmedia_migrate_formatseconds( (int) $seconds_left ); 

Returns (string)

Parameters (1)

0. $seconds_left (int)
The seconds left.

Usage

  1. if ( !function_exists( 'rtmedia_migrate_formatseconds' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'rtmedia-for-wordpress-buddypress-and-bbpress/app/main/controllers/template/rtmedia-functions.php'; 
  3.  
  4. // The seconds left. 
  5. $seconds_left = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = rtmedia_migrate_formatseconds($seconds_left); 
  9.  

Defined (1)

The function is defined in the following location(s).

/app/main/controllers/template/rtmedia-functions.php  
  1. function rtmedia_migrate_formatseconds( $seconds_left ) { 
  2.  
  3. $minute_in_seconds = 60; 
  4. $hour_in_seconds = $minute_in_seconds * 60; 
  5. $day_in_seconds = $hour_in_seconds * 24; 
  6.  
  7. $days = floor( $seconds_left / $day_in_seconds ); 
  8. $seconds_left = $seconds_left % $day_in_seconds; 
  9.  
  10. $hours = floor( $seconds_left / $hour_in_seconds ); 
  11. $seconds_left = $seconds_left % $hour_in_seconds; 
  12.  
  13. $minutes = floor( $seconds_left / $minute_in_seconds ); 
  14. $seconds = $seconds_left % $minute_in_seconds; 
  15.  
  16. $time_components = array(); 
  17.  
  18. if ( $days > 0 ) { 
  19. $time_components[] = $days . ' day' . ( $days > 1 ? 's' : '' ); 
  20.  
  21. if ( $hours > 0 ) { 
  22. $time_components[] = $hours . ' hour' . ( $hours > 1 ? 's' : '' ); 
  23.  
  24. if ( $minutes > 0 ) { 
  25. $time_components[] = $minutes . ' minute' . ( $minutes > 1 ? 's' : '' ); 
  26.  
  27. if ( $seconds > 0 ) { 
  28. $time_components[] = $seconds . ' second' . ( $seconds > 1 ? 's' : '' ); 
  29.  
  30. if ( count( $time_components ) > 0 ) { 
  31. $formatted_time_remaining = implode( ', ', $time_components ); 
  32. $formatted_time_remaining = trim( $formatted_time_remaining ); 
  33. } else { 
  34. $formatted_time_remaining = 'No time remaining.'; 
  35.  
  36. return $formatted_time_remaining; 
  37.