Normalizes an expression as a timestamp.
@param mixed $time the time expression to be normalized
@return int the normalized result as a UNIX timestamp
499840
protected function normalizeDateValue($time)
	{
		if(is_string($time))
		{
			if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
				return (int)$time;
			else
				return strtotime($time);
		}
		elseif (class_exists('DateTime', false) && $time instanceof DateTime)
			return $time->getTimestamp();
		else
			return (int)$time;
	}
1162376
public static function makeTimestamp( $time ) {

		if( is_numeric($time) )
			return (int) $time;

		elseif( $time instanceof \DateTime )
			return $time->getTimestamp();

		$ts = strtotime($time);

		if( $ts === false )
			throw new \LogicException("Unable convert {$time} to a valid timestamp");

		return $ts;

	}
1082438
protected function parseTransactionTimestamp($key)
    {
        $results = [];
        if (preg_match('/^:' . $key . ':(\d{6})/', $this->getCurrentTransactionData(), $results)
            && !empty($results[1])
        ) {
            return $this->sanitizeTimestamp($results[1]);
        }

        return 0;
    }
623209
public function dateString(string $time): string
    {
        return date($this->dateFormat, ctype_digit($time) ? $time : strtotime($time));
    }
52940
public function time($time)
    {
        if ($time instanceof Carbon) {
            $time = $time->timestamp;
        }

        $this->timestamp = $time;

        return $this;
    }
105573
public function diff($time) : DateInterval
    {
        $tmp = new self($time);

        return new DateInterval(abs($this->time - $tmp->getUnixTstamp()));
    }
1244761
private static function timestampToDate($time = null)
    {
        $time = $time ?? time();
        $time = self::formatTime($time);
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($time);

        return $dateTime->format('d-m-Y H:i:s');
    }
300403
public static function getDateTimes($time)
    {

        if (is_numeric($time)) {
            $intTime = $time;
        } else {
            $intTime = strtotime(strval($time));
            if ($intTime === false) {
                throw new \Exception("$time is invalid format");
            }
        }
        $res = date('c', $intTime);

        return substr($res, 0, 19);

    }
757893
public function set_time($time = null) {
        if (empty($time)) {
            $this->time = time();
        } else {
            $this->time = $time;
        }

        return $this;
    }
294420
public static function getReadableTime($time)
    {
        if ($time < 1000) {
            return "{$time}ms";
        }

        $prefix = '';
        if ($time >= 60000) {
            $prefix = floor($time / 60000) . 'm ';
            $time = $time % 60000;
        }

        return $prefix . number_format((float) ($time / 1000), 3, '.', '') . 's';
    }
601272
private static function translateToTimes(string $time) : string
	{
		static $translationMap = [
			'morning' => '06:00 - 11:59',
			'noon' => '12:00 - 12:29',
			'afternoon' => '12:30 - 16:59',
			'evening' => '17:00 - 21:59',
			'night' => '22:00 - 05:59',
			'midnight' => '00:00 - 00:29',
		];

		return array_key_exists($time, $translationMap) ? $translationMap[$time] : $time;
	}
385014
protected function getCorrectTimestamp($time)
    {
        // Get our timestamp (tricky!)
        $time = number_format($time, 0, '.', ''); // save microtime to string
        $time = bcadd($time, '11644473600000', 0); // add epoch time
        $time = bcmul($time, 10000, 0); // tenths of a microsecond.

        $binary = $this->si2bin($time, 64); // create 64 bit binary string
        $timestamp = '';
        for ($i = 0; $i < 8; ++$i) {
            $timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8)));
        }

        return $timestamp;
    }
1132061
protected function microTime($time): int
    {
        if ($time === null) {
            return $this->timestampMicro();
        }

        if ($time instanceof \DateTimeInterface) {
            return (int)round($time->format('U.u') * 1000000, 0);
        }

        if (is_int($time)) {
            return $time;
        }

        if (is_float($time)) {
            return (int)round($time * 1000000, 0);
        }

        throw new \InvalidArgumentException(sprintf(
            'Time should be one of the types int|float|DateTime|null, got %s.',
            gettype($time)
        ));
    }
1265243
public static function getDueDateDelta($time)
    {
        if ( $time < 600 ) {
            $delta = $time . ' seconds';
        } else if ($time < 3600) {
            $delta = sprintf("%0.0f",($time/60.0)) . ' ' . _m('minutes');
        } else if ($time <= 86400 ) {
            $delta = sprintf("%0.2f",($time/3600.0)) . ' ' . _m('hours');
        } else {
            $delta = sprintf("%0.2f",($time/86400.0)) . ' ' . _m('days');
        }
        return $delta;
    }
1239364
public static function windowsFileTimeToUnix($time)
    {
        $magicnum = '116444735995904000';

        $time = bcsub($time, $magicnum);
        $time = bcdiv($time, '10000000', 0);

        return apply_filters('AdApi/Format/WindowsTime', $time);
    }
964410
protected function ago($time)
    {
        $time = time() - $time;

        if ($time < 60) {
            return 'a moment ago';
        }

        $secs = array(
            'year'   => 365.25 * 24 * 60 * 60,
            'month'  => 30 * 24 * 60 * 60,
            'week'   => 7 * 24 * 60 * 60,
            'day'    => 24 * 60 * 60,
            'hour'   => 60 * 60,
            'minute' => 60,
        );

        foreach ($secs as $str => $s) {
            $d = $time / $s;

            if ($d >= 1) {
                $r = round($d);
                return sprintf('%d %s%s ago', $r, $str, ($r > 1) ? 's' : '');
            }
        }
    }
862423
public function setTime($time)
    {
        //argument 1 must be an integer or string
        Argument::i()->test(1, 'int', 'string');
        if (is_string($time)) {
            $time = strtotime($time);
        }

        $this->time = $time - $this->offset;
        return $this;
    }