public static function diff($date1, $date2, $type = 'days', $round = true) {
		$result = strtotime($date2) - strtotime($date1);
		switch ($type) {
			case 'days':
				$result = $result / 86400;
				break;
			case 'abs days':
				$result = abs($result / 86400);
				break;
			case 'seconds':
				return $result;
				break;
			case 'abs seconds':
				return abs($result);
				break;
		}
		// rounding
		if ($round) {
			$result = (int) round($result);
		}
		return $result;
	}
public static function diff($date1, $date2, $type = 'days', $round = true) {
		$result = strtotime($date2) - strtotime($date1);
		switch ($type) {
			case 'days':
				$result = $result / 86400;
				break;
			case 'abs days':
				$result = abs($result / 86400);
				break;
			case 'seconds':
				return $result;
				break;
			case 'abs seconds':
				return abs($result);
				break;
		}
		// rounding
		if ($round) {
			$result = (int) round($result);
		}
		return $result;
	}
public static function diff ( $ date1 , $ date2 , $ type = 'days' , $ round = true ) { $ result = strtotime ( $ date2 ) - strtotime ( $ date1 ) ; switch ( $ type ) { case 'days' : $ result = $ result / 86400 ; break ; case 'abs days' : $ result = abs ( $ result / 86400 ) ; break ; case 'seconds' : return $ result ; break ; case 'abs seconds' : return abs ( $ result ) ; break ; } // rounding if ( $ round ) { $ result = ( int ) round ( $ result ) ; } return $ result ; }
Compute difference between two dates

@param string $date1
@param string $date2
@param string $type
days
abs days
seconds
abs seconds
@param boolean $round
@return mixed
Compute difference between two dates