获得时间戳

@param int $dateTime 默认为空，则以当前时间戳返回
@return int
197107
public static function getTimestamp($dateTime = null)
    {
        return $dateTime ? is_numeric($dateTime) ? $dateTime : strtotime($dateTime) : time();
    }
191991
public function getDatetimeOffset($datetime1, $datetime2 = null)
    {
        if ($datetime2 === null) {
            if ($this->timeType == static::$timeTypeLocal) {
                $datetime2 = $this->currentDatetime();
            } elseif ($this->timeType == static::$timeTypeUtc) {
                $datetime2 = $this->currentUtcDatetime();
            }
        }
        if ($this->timeFormat == static::$timeFormatDatetime) {
            $datetime1 = strtotime($datetime1);
            $datetime2 = strtotime($datetime2);
        }
        return $datetime1 - $datetime2;
    }
1370047
public static function unixTime($dateTime)
    {
        $t = $this->splitDate($dateTime, 'int');

        return mktime($t['hour'], $t['minute'], $t['second'], $t['month'], $t['date'], $t['year']);
    }
853006
static function parserDateTime($dateTime)
    {
        if (!$dateTime instanceof \DateTime) $dateTime = static::createDateTimeClass($dateTime);
        $year = $dateTime->format('Y');
        $day = $dateTime->format('j');
        $month = $dateTime->format('n');
        $hour = $dateTime->format('H');
        $minute = $dateTime->format('i');
        $second = $dateTime->format('s');
        return [ $hour, $minute, $second, $month, $day, $year ];
    }
143986
public static function fatorVencimento(\DateTime $data)
    {
        $dataBase = new \DateTime("1997-10-07");

        return (int)$data->diff($dataBase, true)->format('%r%a');
    }
1315227
public function count($count = false): int
    {
        // 如果不传递参数,返回记录总数
        if ($count === false) {
            return $this->count;
        }

        // 记录总数
        $this->count = intval($count);

        // 计算总页数
        $this->allPage = ceil($count / $this->size);

        // 调整当前页数,不能大于总页数
        $this->page = max(1, min($this->page, $this->allPage));

        return $this->count;
    }
822998
private function getFormattedTimestamp($dateTime) {
    if (!is_object($dateTime)) {
      if (is_string($dateTime)) {
        $dateTime = new DateTime($dateTime);
      } else {
        throw new Exception("Invalid date value.");
      }
    } else {
      if (!($dateTime instanceof DateTime)) {
        throw new Exception("Invalid date value.");
      }
    }
    
    return $dateTime->format(DATE_ISO8601);  
  }
1355880
public function hourIndex($datetime, $hours)
    {
        $searchedHour = date('G', $datetime->getTimestamp());

        return $this->getIndex($searchedHour, $hours);
    }
19150
public function getAge() {
		if($this->Started) {
			$started = intval($this->dbObject('Started')->Format('U'));
			$now = intval(SS_Datetime::now()->Format('U'));
			if($started && $now) return $now - $started;
		}
		return 0;
	}
442564
private static function validateDateTime($datetime)
	    {
	        if ($datetime instanceof DateTimeInterface || $datetime instanceof DateTime) {
	            return $datetime;
	        }

	        return new DateTime((string) $datetime);
	    }
538033
protected function getDateTimeInstance(string $time = "now", \DateTimeZone $timezone = null): DateTime
    {
        $result = new self::$_dateTimeClassName($time, $timezone);

        return $result;
    }
411856
public function containsExclusive(DateTime $dateTime) : bool
    {
        return $this->start->comesBefore($dateTime) && $this->end->comesAfter($dateTime);
    }
844973
public function isExpired(DateTime $dateTime)
    {
        if (null === $this->getExpiresIn()) {
            // if no expiry was indicated, assume it is valid
            return false;
        }

        // check to see if issuedAt + expiresIn > provided DateTime
        $expiresAt = clone $this->issuedAt;
        $expiresAt->add(new DateInterval(\sprintf('PT%dS', $this->getExpiresIn())));

        return $dateTime >= $expiresAt;
    }
1228393
public function transform($dateTime): ?int
    {
        if (null === $dateTime) {
            return null;
        }

        if (!$dateTime instanceof \DateTimeInterface) {
            throw new TransformationFailedException('Expected a \DateTimeInterface.');
        }

        return $dateTime->getTimestamp();
    }
1271846
public static function lowest(... $datetimes)
    {
        $lowest = null;
        foreach ($datetimes as $datetime) {
            if (!$datetime instanceof \DateTimeInterface) {
                continue;
            }

            if ($datetime < $lowest || null === $lowest) {
                $lowest = $datetime;
            }
        }

        return $lowest;
    }
593137
public static function fromNativeDateTime(\DateTime $time)
    {
        $hour   = \intval($time->format('G'));
        $minute = \intval($time->format('i'));
        $second = \intval($time->format('s'));

        return static::fromNative($hour, $minute, $second);
    }
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);

    }