@param mixed $timestamp

@return \DateTime
549292
public static function createDateTimeFromTimestampWithMilliseconds($timestamp)
    {
        // manage negative timestamps (before unix epoch)
        if ($timestamp < 0) {
            $datetime = new \DateTime();
            $datetime = $datetime->setTimestamp($timestamp);
        } else {
            $datetime = \DateTime::createFromFormat('U.u', $timestamp, new \DateTimeZone('UTC'));

            if ($datetime == false) {
                $datetime = \DateTime::createFromFormat('U', $timestamp, new \DateTimeZone('UTC'));
            }
        }

        if ($datetime == false) {
            throw new \RuntimeException(
                sprintf('Could not create datetime from "%s": %s',
                    $timestamp,
                    print_r(\DateTime::getLastErrors(), true)
                )
            );
        }

        return $datetime;
    }
372607
public static function formatDate($format, $timestamp)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = "/\b(" . implode('|', array_keys(static::$_map['date'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
            $timesPatterns = "/\b(" . implode('|', array_keys(static::$_map['time'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
        }

        // normalize formats
        $result = preg_replace_callback($datesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['date'][$matches[1]], $timestamp);
        }, trim($format));

        $result = preg_replace_callback($timesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['time'][$matches[1]], $timestamp);
        }, $result);

        return str_replace('\'', '', $result);
    }
185904
public static function fromTimestamp($timestamp, DateTimeZone $dateTimeZone = null)
    {
        $base = new GregorianDateTime(
            date('Y-m-d H:i:s', $timestamp),
            self::checkForDateTimeZone($dateTimeZone)
        );

        return new DateTime($base);
    }
5541
public static function unixToJd($timestamp)
    {
        if ($timestamp < 0) {
            return false;
        } else {
            // Convert timestamp based on local timezone
            return self::GregorianToJd(gmdate('n', $timestamp), gmdate('j', $timestamp), gmdate('Y', $timestamp));
        }
    }
346317
public function setExpires($timestamp)
    {
        $this->data['Expires'] = is_numeric($timestamp)
            ? (int) $timestamp
            : strtotime($timestamp);

        return $this;
    }
729947
public function setTimestamp($timestamp = null)
    {
        $this->timestamp = (string)($timestamp ?? $this->modified());

        return $this;
    }
399399
public static function roundTimestampDownToMonth($timestamp)
    {
        $month = date('n', $timestamp);
        $year  = date('Y', $timestamp);
                
        $roundedTimestamp = mktime(0, 0, 0, $month, $day="01", $year);
                
        return $roundedTimestamp;
    }
927799
public static function fromMilliseconds($timestamp = null)
    {
        if (! $timestamp) {
            return null;
        }

        return Carbon::createFromTimestamp(self::toSeconds($timestamp));
    }
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;
    }
611455
public function getDelayedTimestampSize($timestamp)
    {
        $timestamp = $this->toTimestamp($timestamp);
        return $this->redis->llen('delayed:' . $timestamp, $timestamp);
    }
772021
private static function _createFromTimestamp($timestamp) {
        // Creates an instance of the current class
        $date = new DateMilli();
        // Creates the DateTime PHP object from the given timestamp
        $dateTime = new \DateTime();
        // Check if the given timestamp is a float value (which means it contains milliseconds)
        $intValue = (int) $timestamp;
        $date->_setMilliseconds((float) ($timestamp - $intValue) * 1000);
        $timestamp = $intValue;
        if ($dateTime->setTimestamp($timestamp) === false) {
            throw new DateMilliException('Impossible to create a Date object from the given timestamp value [' . $timestamp . ']');
        }

        // Set the PHP DateTime instance property
        $date->_dateTime = $dateTime;

        return $date;
    }
585229
public function setTimestamp($timestamp = null)
    {
        $this->timestamp = $timestamp;
        if ($timestamp === null) {
            $this->timestamp = new Timestamp();
        }
        return $this;
    }
1219750
public function getMinute($timestamp = false)
    {
        if (!$timestamp) {
            $timestamp = $this->dateTime->getTimestamp();
        }

        return date('i', $timestamp);
    }
751370
public final function last(int $timeStamp = null): string
   {
       if ($timeStamp) {
           $this->lastModification = gmdate(
               "D, d M Y H:i:s",
               $timeStamp) . " GMT";
       }
       return $this->lastModification;
   }
170565
protected function formatDateTime($format, $time = 'now', $timestamp = false)
    {
        if (empty($time)) {
            return;
        }

        if (false === $format) {
            return $time;
        } elseif (false !== strpos($format, '\\')) {
            return new $format($time);
        }

        if ($timestamp) {
            $dateTime = new DateTime();
            $dateTime->setTimestamp($time);
        } else {
            $dateTime = new DateTime($time);
        }

        return $dateTime->format($format);
    }
771243
public function fromRedisTimestamp($timestamp) : DateTime
    {
        $date = DateTime::createFromFormat('U', $timestamp);
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
66002
public function setTimestamp($timestamp = 0)
    {
        $this->timestamp = $timestamp;
        if ($timestamp === 0) {
            $this->timestamp = $this->generateTimestamp();
        }
        return $this;
    }