You are here

function event_duration in Event 5.2

Return a timespan (in days) between two dates

@parem $type Type of results

Parameters

$start The first date:

$end The second date:

Return value

The duration in days (if $type = days) or seconds if ($type = 'seconds').

File

./event.module, line 3055

Code

function event_duration($start, $end, $type = 'days') {
  switch ($type) {
    case 'seconds':
      return mktime($end['hour'], $end['minute'], $end['second'], $end['month'], $end['day'], $end['year']) - mktime($start['hour'], $start['minute'], $start['second'], $start['month'], $start['day'], $start['year']);
      break;
    default:
      return floor((mktime(12, 0, 0, $end['month'], $end['day'], $end['year']) - mktime(12, 0, 0, $start['month'], $start['day'], $start['year'])) / 86400);
  }
}