You are here

function _simpleads_date_diff in SimpleAds 7

Helper function. Timestamp to days.

1 call to _simpleads_date_diff()
simpleads_simpleads_stats_info in ./simpleads.module
Implements hook_simpleads_stats_info().

File

./simpleads.stat.inc, line 280
SimpleAds Statistics.

Code

function _simpleads_date_diff($node) {
  $start_time = "";
  $end_time = "";
  if (isset($node->field_ad_start_date[$node->language]) && !empty($node->field_ad_start_date[$node->language][0]['value'])) {
    $start_time = $node->field_ad_start_date[$node->language][0]['value'];
  }
  if (isset($node->field_ad_end_date[$node->language]) && !empty($node->field_ad_end_date[$node->language][0]['value'])) {
    $end_time = $node->field_ad_end_date[$node->language][0]['value'];
  }
  $ustart_time = strtotime($start_time);
  $uend_time = strtotime($end_time);
  $now = time();
  if ($ustart_time == '' && $uend_time != '') {
    return floor(($uend_time - $now) / 86400);
  }
  elseif ($ustart_time != '' && $uend_time != '') {
    return floor(($uend_time - $ustart_time) / 86400);
  }
  elseif ($ustart_time == '' && $uend_time == '') {
    return FALSE;
  }
  else {
    return 0;
  }
}