Create and return a DateMilli object from a given timestamp

@param float $timestamp a Unix timestamp, including milliseconds
@return DateMilli
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;
    }
59262
public function dayname($timestamp = 0)
    {
        $day = (int) date('w', $timestamp);

        return $this->translator->_($this->day[$day]);
    }
299046
public function date($timestamp, $full = true)
    {
        if ($full) {
            $format = $this->config->get('date_full_format', 'd.m.Y H:i');
        } else {
            $format = $this->config->get('date_short_format', 'd.m.y');
        }

        return date($format, $timestamp);
    }
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);
    }
1225469
public function setThaiYear(DateTime $timestamp){
        if($this->checkThaiLocale()){
            return $timestamp->setDate(($timestamp->format('Y')+543),$timestamp->format('m'),$timestamp->format('d'));
        }else{
            return $timestamp;
        }
    }
287948
public static function formatTimestamp($timestamp)
    {
        $rfc3339 = '/^(\d{4})\-?(\d{2})\-?(\d{2})((T|t)(\d{2})\:?(\d{2})' .
                   '\:?(\d{2})(\.\d{1,})?((Z|z)|([\+\-])(\d{2})\:?(\d{2})))?$/';

        if (ctype_digit((string)$timestamp)) {
            return gmdate('Y-m-d\TH:i:sP', $timestamp);
        } elseif (preg_match($rfc3339, $timestamp) > 0) {
            // timestamp is already properly formatted
            return $timestamp;
        } else {
            $ts = strtotime($timestamp);
            if ($ts === false) {
                require_once 'Zend/Gdata/App/InvalidArgumentException.php';
                throw new Zend_Gdata_App_InvalidArgumentException("Invalid timestamp: $timestamp.");
            }
            return date('Y-m-d\TH:i:s', $ts);
        }
    }
927799
public static function fromMilliseconds($timestamp = null)
    {
        if (! $timestamp) {
            return null;
        }

        return Carbon::createFromTimestamp(self::toSeconds($timestamp));
    }
333160
public function setTimestamp($timestamp)
    {
        if (self::$_immutable) {
            self::$_immutable = false;
            $newDate = clone $this;
            $newDate->setTimestamp($timestamp);
            self::$_immutable = true;

            return $newDate;
        } else {
            return parent::setTimestamp($timestamp);
        }
    }
356678
private function timecode(int $timestamp): int
    {
        return (int) floor(($timestamp - $this->getEpoch()) / $this->getPeriod());
    }
936232
public function setTimestamp($timestamp)
    {
        $this->timestamp = is_numeric($timestamp) ? $timestamp : strtotime($timestamp);

        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);
    }
534163
public static function getFormatedDate($timestamp)
    {
        return MTimestampHelper::getDay($timestamp) . "." . MTimestampHelper::getMonth($timestamp) . "." . MTimestampHelper::getYear($timestamp);
    }
447204
public static function timestamp($timestamp = null)
    {
        if (!self::isDebug()) {
            return false;
        }

        $date = date(DATE_RFC822, $timestamp);
        return self::i()->dump($date, $timestamp . ' sec = ');
    }
1040255
public function getSecond($timestamp = false)
    {
        if (!$timestamp) {
            $timestamp = $this->dateTime->getTimestamp();
        }

        return (int) date('s', $timestamp);
    }
554809
public static function roundTimestampToWeek($timestamp)
    {        
        $roundedToDay = self::roundTimestampToDay($timestamp);
        $weekDay  = date('w', $roundedToDay); # 1 = Monday
        $daysToSubtract = $weekDay - 1;
        $roundedToWeek = strtotime("-" . $daysToSubtract . " day", $roundedToDay);
        
        return $roundedToWeek;
    }
383635
public function convert_date_to_iso8601($datestamp)
	{
		if (!preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}((\+|-)\d{2}:\d{2}|Z)/m', $datestamp))
		{
			return gmdate(self::DATE_FORMAT_ISO8601, strtotime($datestamp));
		}

		return $datestamp;
	}
457674
public static function fromTimestamp(int $timestamp, ?string $timezone = null): Time
    {
        $timezone = $timezone ?: date_default_timezone_get();
        assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));

        $time = sprintf('%d', $timestamp);
        $dateTime = DateTimeImmutable::createFromFormat('U', $time, new DateTimeZone('UTC'));
        $dateTime = $dateTime->setTimezone(new DateTimeZone($timezone));
        $hour = (int) $dateTime->format('G');
        $minute = (int) $dateTime->format('i');
        $second = (int) $dateTime->format('s');

        return new static($hour, $minute, $second);
    }