monsterinsights_hours_between

Hours between two timestamps.

Description

(int) monsterinsights_hours_between( (string) $start, (bool) $stop = false ); 

Returns (int)

Hours between the two timestamps, rounded.

Parameters (2)

0. $start (string)
Timestamp of start time (in seconds since Unix).
1. $stop — Optional. (bool) => false
Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used.

Usage

  1. if ( !function_exists( 'monsterinsights_hours_between' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/helpers.php'; 
  3.  
  4. // Timestamp of start time (in seconds since Unix). 
  5. $start = ''; 
  6.  
  7. // Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used. 
  8. $stop = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = monsterinsights_hours_between($start, $stop); 
  12.  

Defined (1)

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

/includes/helpers.php  
  1. function monsterinsights_hours_between( $start, $stop = false ) { 
  2. if ( $stop === false ) { 
  3. $stop = time(); 
  4.  
  5. $diff = (int) abs( $stop - $start ); 
  6. $hours = round( $diff / HOUR_IN_SECONDS ); 
  7. return $hours;