twitter_stream_time_ago

The Twitter Stream twitter stream time ago function.

Description

twitter_stream_time_ago( $time ); 

Parameters (1)

0. $time
The time.

Usage

  1. if ( !function_exists( 'twitter_stream_time_ago' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'twitter-stream/twitter-stream.php'; 
  3.  
  4. // The time. 
  5. $time = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = twitter_stream_time_ago($time); 
  9.  

Defined (1)

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

/twitter-stream.php  
  1. function twitter_stream_time_ago($time) 
  2. $singular = array(__("second", 'twit_stream'), __("minute", 'twit_stream'), __("hour", 'twit_stream'), __("day", 'twit_stream'), __("week", 'twit_stream'), __("month", 'twit_stream'), __("year", 'twit_stream'), __("decade", 'twit_stream')); 
  3. $plural = array(__("seconds", 'twit_stream'), __("minutes", 'twit_stream'), __("hours", 'twit_stream'), __("days", 'twit_stream'), __("weeks", 'twit_stream'), __("months", 'twit_stream'), __("years", 'twit_stream'), __("decades", 'twit_stream')); 
  4. $lengths = array("60", "60", "24", "7", "4.35", "12", "10"); 
  5.  
  6. $now = time(); 
  7.  
  8. $difference = $now - $time; 
  9. $tense = __("ago", 'twit_stream'); 
  10.  
  11. for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { 
  12. $difference /= $lengths[$j]; 
  13.  
  14. $difference = round($difference); 
  15.  
  16. if($difference != 1) { 
  17. $period = $plural[$j]; 
  18. } else { 
  19. $period = $singular[$j]; 
  20.  
  21. //French translation fix 
  22. if(strcasecmp(get_bloginfo('language'), 'fr-FR') === 0) { 
  23. return "{$tense} {$difference} {$period}"; 
  24. } else { 
  25. return "{$difference} {$period} {$tense}";