Converts a Redis Unix timestamp to a PHP timestamp

@param int $timestamp The Unix timestamp to convert from
@return DateTime The PHP timestamp
771243
public function fromRedisTimestamp($timestamp) : DateTime
    {
        $date = DateTime::createFromFormat('U', $timestamp);
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
1122207
public function setExpires($timestamp)
    {
        if (strpos('GET,OPTIONS', $this->request->getServer('REQUEST_METHOD')) !== false) {
            if ($timestamp <= 2592000) {
                $timestamp += time();
            }

            $date = new \DateTime('now', new \DateTimeZone('UTC'));
            $date->setTimestamp($timestamp);

            $this->setHeader('Expires', $date->format('D, d M Y H:i:s') . ' GMT');
        }

        return $this;
    }
966897
public static function unix2dos(int $timestamp = 0) : int
    {
        $timestamp = ($_timestamp == 0) ? getdate() : getdate($_timestamp);

        if ($timestamp['year'] < 1980) return (1 << 21 | 1 << 16);

        $timestamp['year'] -= 1980;

        return ($timestamp['year']    << 25 | $timestamp['mon']     << 21 |
                $timestamp['mday']    << 16 | $timestamp['hours']   << 11 |
                $timestamp['minutes'] << 5  | $timestamp['seconds'] >> 1);
    }
430489
public function elapsedTime($timestamp)
    {
        if ($timestamp instanceof DateTime) {
            $timestamp = $timestamp->format('U');
        } else if (is_string($timestamp)) {
            $timestamp = strtotime($timestamp);
        }
        
        $diff = time() - $timestamp; 
        $periods = self::$texts['times']; 
        $lengths = array(60, 60, 24, 7, 4.35, 12, 10); 
        $ending = self::$texts['ago'];
        
        if ($diff < 60) {
            return self::$texts['less_than_a_minute'];
        } else if ($diff < 0) {
            $diff = -$diff; 
            $ending = self::$texts['togo']; 
        }
              
        for($j = 0; $j < count($lengths) && $diff >= $lengths[$j]; $j++) {
            $diff /= $lengths[$j]; 
        }
        $diff = round($diff); 
        if($diff != 1) {
            $periods[$j].= "s"; 
        }
        
        if (self::$agoAfter) {
            return "$diff $periods[$j] $ending";
        } else {
            return "$ending $diff $periods[$j]";
        }
    }
59262
public function dayname($timestamp = 0)
    {
        $day = (int) date('w', $timestamp);

        return $this->translator->_($this->day[$day]);
    }
733176
protected function replaceDateTime($string, $timestamp)
    {
        foreach(static::DATE_FORMATS as $format)
        {
            $string = str_replace('{' . $format . '}', date($format, $timestamp), $string);
        }
        return $string;
    }
957326
protected function _parseTimestamp($timestamp)
    {
        if (is_null($timestamp))
            return AbstractQuery::getCurrentTimestamp();

        if (!AbstractQuery::isValidTimestamp($timestamp)) {
            if ($sTime = strtotime($timestamp)) {
                $timestamp = date('YmdHis', $sTime);
            } else {
                throw oxNew(
                    ConsoleException::class,
                    'Invalid timestamp format, use YYYYMMDDhhmmss format'
                );
            }
        }

        return $timestamp;
    }
803826
public static function timestampToGermanDateFormat(int $timestamp): string {
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($timestamp);
        $format = $dateTime->format(DateTimeUtil::GERMAN_DATE_TIME_FORMAT);
        return $format;
    }
203187
public function setTimestamps($timestamp = null)
    {
        /** @var Medium $instance */
        foreach ($this->items as $instance) {
            $instance->setTimestamp($timestamp);
        }

        return $this;
    }
64901
public static function getISO8601($timestamp=false) {
        if ( $timestamp === false ) {
            $dt = new \DateTime();
        } else {
            $format = 'Y-m-d H:i:s';
            $dt = \DateTime::createFromFormat($format, $timestamp);
        }

        // 2017-08-16T16:26:31-1000
        $iso8601 = $dt->format(\DateTime::ISO8601);

        // 2017-08-20T10:34:05.000Z
        $iso8601 = str_replace('-1000','.000Z',$iso8601);

        return $iso8601;
    }
303495
public static function format($timestamp): string
    {
        $str = '';
        $timestamp = round($timestamp * 1000);
        foreach (self::TIME as $unit => $value) {
            if ($timestamp >= $value) {
                $time = floor($timestamp / $value * 100.0 / 100.0);

                if ($time > 0) {
                    $str .= $time.' '.$unit.($time === 1.0 ? '' : 's').' ';
                }
                $timestamp -= ($time * $value);
            }
        }

        if ($timestamp > 0) {
            $str .= $timestamp.' ms';
        }

        return trim($str);
    }
717796
public function format($format = 'date', $timestamp = null)
    {
        $timestamp = is_numeric($timestamp) ? '@'.intval($timestamp) : $timestamp;
        $timestamp = is_a($timestamp, 'DateTime') ? $timestamp : new DateTime($timestamp);

        $key = $this->getTranslationKey("date.formats.{$format}");
        $format = $this->translator->has($key) ? $this->translator->get($key) : null;

        if (is_null($format)) {
            throw new \InvalidArgumentException('Date format is invalid or does not exists in current language');
        }

        return strftime($format, $timestamp->format('U'));
    }
1371418
protected function getJql($timestamp)
    {
        if (!isset($timestamp)) {
            return $this->jql;
        }

        return $this->jql . " AND updated > '" . date('Y-m-d H:i', $timestamp) . "'";
    }
426863
public function setTimestamp($timestamp)
    {
        if (!$timestamp instanceof \DateTime) {
            $date = new \DateTime();
            $date->setTimestamp($timestamp);
        } else {
            $date = $timestamp;
        }
        $this->header['TIMESTAMP'] = $date->format('M d H:i:s');
        return $this;
    }
1057729
protected function hourFloor($timestamp)
    {
        return mktime(date('H', $timestamp), 0, 0, date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
    }
724399
public static function fromTimestampWithMicroseconds(int $timestamp) : self
    {
        $seconds      = (int)($timestamp / 10 ** 6);
        $microseconds = $timestamp - ($seconds * 10 ** 6);

        // Ensure microseconds are right-padded with zeros because values like 012345 will be 12345 when expressed
        // as an integer, and the concatenation below will therefore shift digits left by one place.
        $microseconds = str_pad($microseconds, 6, '0', STR_PAD_LEFT);
        
        return static::fromFormat('U.u', $seconds . '.' . $microseconds);
    }
559101
protected function formatDatetime($timestamp = 0, $format = '')
    {
        switch ($this->timeset) {
            case 1:
                // swatch date
            return $this->swatchDate($timestamp).' � '.$this->swatchTime($timestamp);
            break;
            case 2:
                // iso date
            return $this->unixTimestampToISOdatetime($timestamp);
            break;
            default:
                // default time
            return date($this->dateFilter($format, $timestamp), $timestamp);
            break;
        }
    }