Diff the time results to each other and convert to nanoseconds if needed.

@param  float|int  $start
@param  float|int  $end
@return int
963528
protected function diffTimeInNanoseconds($start, $end): int
    {
        if ($this->platformSupportsNanoseconds()) {
            return $end - $start;
        }

        // Difference is in seconds (with microsecond precision)
        // * 1000 to get to milliseconds
        // * 1000 to get to microseconds
        // * 1000 to get to nanoseconds
        return (int) (($end - $start) * 1000 * 1000 * 1000);
    }
294390
public static function calcElapsedTime($start, $end, $precision = 8) {
		$elapsed = $end - $start;
		return round($elapsed, $precision);
	}
462085
def get_time_diff_days(start, end):
    '''   '''

    if start is None or end is None:
        return None

    if type(start) is not datetime.datetime:
        start = parser.parse(start).replace(tzinfo=None)
    if type(end) is not datetime.datetime:
        end = parser.parse(end).replace(tzinfo=None)

    seconds_day = float(60 * 60 * 24)
    diff_days = (end - start).total_seconds() / seconds_day
    diff_days = float('%.2f' % diff_days)

    return diff_days
899368
public static long getMillisDifference(Date startDate, Date endDate) {
		long startTime = startDate.getTime();
		long endTime = endDate.getTime();
		long diffTime = endTime - startTime;
		return diffTime;
	}
1055634
public static function diffDateTimeDays($dateTimeStart, $dateTimeEnd)
    {
        $dateStart = self::cutTime($dateTimeStart);
        $dateEnd = self::cutTime($dateTimeEnd);
        $secondsDiff = self::diffDateTimeSeconds($dateStart, $dateEnd);
        $daysDiff = $secondsDiff / 3600 / 24;
        return $daysDiff;
    }
843571
public function addMeasure($label, $start, $end)
    {
        if ($this->hasCollector('time')) {
            /** @var \DebugBar\DataCollector\TimeDataCollector $collector */
            $collector = $this->getCollector('time');
            $collector->addMeasure($label, $start, $end);
        }
    }
1003417
protected function _dateDiff($start = null, $stop = null) {
		if ($start) {
			$endDate = $stop instanceof DateTime ? $stop : new DateTime($stop ? $stop : 'now');
			$startDate = $start instanceof DateTime ? $start : new DateTime($start);
			$diff = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat'));
			return $this->_isCli ? $diff : $this->Html->tag('span', $diff);
		} else {
			return $this->_none();
		}
	}
809364
static public function elapsedTime($start, $end) {
        $start = isset(self::$_marks[$start]) ? self::$_marks[$start]['time'] : 0;
        $end = isset(self::$_marks[$end]) ? self::$_marks[$end]['time'] : 0;

        return $start ? round($end - $start, 10) : null;
    }
1208299
public static function stop_timer( $start ) {
		$time = microtime();
		$time = explode(' ', $time);
		$time = $time[1] + $time[0];
		$finish = $time;
		$total_time = round(($finish - $start), 4);
		return $total_time.' seconds.';
	}
369840
public function diff($start, $end, $level = 'MB')
    {
        $startPoint = $this->getPoint($start);
        $endPoint   = $this->getPoint($end);

        return [
            'time'   => $endPoint['time'] - $startPoint['time'],
            'memory' => ($endPoint['memory'] - $startPoint['memory']) / pow(1024, (int) array_search($level, $this->memoryLevel))
        ];
    }
1372283
public static long getTimeSpan(Date begin, Date end, int type) {
        long diff = end.getTime() - begin.getTime();
        switch (type) {
            case DAY:
            default:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_DAY;
            case HOUR:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_HOUR;
            case MINUTE:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_MINUTE;
            case SECOND:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_SECOND;
        }
    }
512799
public static function years(int $start = 1980, int $end = 2024) : array
    {
        return Date::_range(1, $start, $end, true);
    }
983245
public function substr(int $start, int $end): string
    {
        return $this->handle->getRange($this->name, $start, $end);
    }
550432
public function computeNumTimesFiredBetween(\DateTime $start, \DateTime $end)
    {
        if ($this->getRepeatInterval() < 1) {
            return 0;
        }

        $time = ((int) $end->format('U')) - ((int) $start->format('U'));

        return (int) ($time / $this->getRepeatInterval());
    }
599773
public static function getDateTimeRange($start, $end = null, $exact = false)
    {
        return [
            static::buildDateTime($start, !$exact),
            static::buildDateTime($end ?: $start, false, !$exact),
        ];
    }
984215
public static long getMinutesDifference(Date startDate, Date endDate) {
		long startTime = startDate.getTime();
		long endTime = endDate.getTime();
		long diffTime = endTime - startTime;
		long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffTime);
		return diffInMinutes;
	}
663866
public static function timeDifferent($time1, $time2)
    {
        $intTime1 = $this->unixTime($time1);
        $intTime2 = $this->unixTime($time2);
        $timeDiff = $intTime2 - $intTime1;

        return $timeDiff;
    }