Converts a date from ISO 8601 format in UTC timezone to unix timestamp.

@param string $isoTime date in ISO 8601 format
@return int unix timestamp
494417
public function utcIsoToTimestamp($isoTime)
    {
        $utcTimeZone = new \DateTimeZone('UTC');
        $dateTime = \DateTime::createFromFormat(self::SOLR_ISO_DATETIME_FORMAT,
            $isoTime, $utcTimeZone);
        return $dateTime ? (int)$dateTime->format('U') : 0;
    }
893185
def _convert_ftp_time_to_iso(ftp_time):
        
        date_time = datetime(
            int(ftp_time[:4]), int(ftp_time[4:6]), int(ftp_time[6:8]),
            int(ftp_time[8:10]), int(ftp_time[10:12]), int(ftp_time[12:14]))
        return date_time
1155577
public function createDateTimeByUnixTime($unixTime)
    {
        $dateTime = new \DateTime('@' . $unixTime);
        $dateTime->setTimezone($this->specifiedTimeZone);

        return $dateTime;
    }
1314438
def isotime(at=None, subsecond=False):
    """"""
    if not at:
        at = utcnow()
    st = at.strftime(_ISO8601_TIME_FORMAT
                     if not subsecond
                     else _ISO8601_TIME_FORMAT_SUBSECOND)
    tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
    st += ('Z' if tz == 'UTC' else tz)
    return st
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');
    }
44936
private function to8601Utc(\DateTimeInterface $dateTime): string
    {
        // Convert to UTC if we can
        if ($dateTime instanceof DateTime) {
            $dateTime->setTimezone(new \DateTimeZone('UTC'));
        } elseif ($dateTime instanceof \DateTimeImmutable && $dateTime->getOffset() > 0) {
            // Some implementations will be wrong since we're effectively dropping the offset from the datetime format
            // and this interface doesn't allow us to make modifications so we reject the timestamp altogether to ensure
            // only correct timestamps make it through.
            throw new InvalidArgumentException('Timestamp must be UTC');
        }

        // PHP's default 8601 format contains a portion that includes the timezone offset.  The Mailbox API doesn't
        // like the offset and requires a timestamp without it, thus requiring all inbound timestamps to be UTC
        return $dateTime->format('Y-m-d\TH:i:s\Z');
    }
197107
public static function getTimestamp($dateTime = null)
    {
        return $dateTime ? is_numeric($dateTime) ? $dateTime : strtotime($dateTime) : time();
    }
291822
public static function convertToDbDate(\DateTime $dateTime) {
		
		$currentTz = $dateTime->getTimezone();
		$dateTime->setTimezone(new \DateTimeZone(BASE_TIMEZONE));
		$ret = $dateTime->format('Y-m-d');
		$dateTime->setTimezone($currentTz);
		return $ret;
		
	}
938712
public static function timestampToGmt($time = null)
    {
        $time = $time ?? time();
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($time)->modify('+2 hours');

        return $dateTime->format('d/m/Y H:i:s');
    }
740802
public static function unixtimeFormat($time)
    {
        $v = time() - $time;
        $v = $v > 0 ? $v : 0;
        if ($v < 60) {
            $format = '刚刚';
        } else if ($v < 60 * 60) {
            $format = strval(floor($v / 60)) . '分钟前';
        } else if ($v < 60 * 60 * 24) {
            $format = strval(floor($v / 60 / 60)) . '小时前';
        } else {
            $format = strval(floor($v / 60 / 60 / 24)) . '天前';
        }
        return $format;
    }
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']);
    }
645318
public static function createFromDateString($time)
    {
        $interval = parent::createFromDateString($time);
        if ($interval instanceof DateInterval && !($interval instanceof static)) {
            $interval = static::instance($interval);
        }

        return static::instance($interval);
    }
855573
public function timeString(string $time): string
    {
        return date($this->timeFormat, ctype_digit($time) ? $time : strtotime($time));
    }
875901
public static function isoDate($timestamp = null)
    {
        $tz = date_default_timezone_get();
        date_default_timezone_set('UTC');

        if (is_null($timestamp)) {
            $timestamp = time();
        }

        $returnValue = str_replace(
            '+00:00', '.0000000Z', date('c', $timestamp)
        );
        date_default_timezone_set($tz);

        return $returnValue;
    }
957168
public function dateTimeString(string $time): string
    {
        return date($this->dateTimeFormat, ctype_digit($time) ? $time : strtotime($time));
    }
89552
protected function isoDateToHuman($isodate)
    {
        $isodate = str_replace(" 00:00:00", "", $isodate);
        $datetime = \DateTime::createFromFormat( 'Y-m-d', $isodate);
        if (!$datetime || $isodate == '0000-00-00') return '';

        $isodate = $datetime->format($this->format);
        return $isodate;
    }
1163557
public static function timestamp($time = null): int
    {
        if ($time instanceof \DateTime) {
            return $time->format('U');
        }

        $time = time();

        if ($time !== null) {
            $time = is_numeric($time) ? (int) $time : strtotime($time);
        }

        return $time;
    }