Get datetime as a timestamp.

@param int $timestamp timestamp on origin

@return static

@since 1.0.3
510525
public function fromTimestamp($timestamp, $timezone = 'UTC')
    {
        // [TODO] use DateTime object for parse timestamp
        $oldTz = date_default_timezone_get();
        date_default_timezone_set($timezone);
        $timestamp = mktime(date('H', $timestamp), date('i', $timestamp), date('s', $timestamp), date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
        date_default_timezone_set('UTC');
        $utcDT = gmdate('c', $timestamp);
        $dateArray = getdate(strtotime(gmdate('c', $timestamp)));
        date_default_timezone_set($oldTz);
        unset($dateArray[0]);

        $this->from($dateArray, 'en_US', null, $timezone);

        return $this;
    }
380385
public function setTimestamp( $timestamp ) {
		$instance = parent::setTimestamp( $timestamp );
		list(
			$instance->arYear,
			$instance->arMonth,
			$instance->arDay
			) = ( new Date() )->hjConvert( $instance->year, $instance->month, $instance->day );
		
		return $instance;
	}
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);
    }
1297283
function get_timestamp() {
        if (!empty($this->timestamp)) {
            $timestamp = $this->timestamp;
            unset($this->timestamp);
            return $timestamp;
        }
        return time();
    }
346317
public function setExpires($timestamp)
    {
        $this->data['Expires'] = is_numeric($timestamp)
            ? (int) $timestamp
            : strtotime($timestamp);

        return $this;
    }
683394
public static function ToTimezone($Timestamp) {
      static $GuestHourOffset;
      $Now = time();
      
      // Alter the timestamp based on the user's hour offset
      $Session = Gdn::Session();
      $HourOffset = 0;
      
      if ($Session->UserID > 0) {
         $HourOffset = $Session->User->HourOffset;
      } elseif (class_exists('DateTimeZone')) {
         if (!isset($GuestHourOffset)) {
            $GuestTimeZone = C('Garden.GuestTimeZone');
            if ($GuestTimeZone) {
               try {
                  $TimeZone = new DateTimeZone($GuestTimeZone);
                  $Offset = $TimeZone->getOffset(new DateTime('now', new DateTimeZone('UTC')));
                  $GuestHourOffset = floor($Offset / 3600);
               } catch (Exception $Ex) {
                  $GuestHourOffset = 0;
                  LogException($Ex);
               }
            }
         }
         $HourOffset = $GuestHourOffset;
      }
      
      if ($HourOffset <> 0) {
         $SecondsOffset = $HourOffset * 3600;
         $Timestamp += $SecondsOffset;
         $Now += $SecondsOffset;
      }
      
      return $Timestamp;
   }
489866
protected function hourCeil($timestamp)
    {
        return mktime(date('H', $timestamp) + 1, 0, 0, date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
    }
858142
private static function _timestampToUTC($timestamp)
    {
        $tz = new DateTimeZone('UTC');
        $dateTime = new DateTime($timestamp, $tz);
        $dateTime->setTimezone($tz);
        return $dateTime;
    }
964077
public static Date getFromTimestamp(Timestamp timestamp) {
        if (timestamp == null) {
            return null;
        }
        return new Date(timestamp.getTime());
    }
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;
        }
    }
679115
public static function dateTime ($date, $timestamp = FALSE) {
		return ($timestamp) ? date('c',$date) : date('c', strtotime($date));
	}
337439
function setTimeStamp( $timestamp )
    {
        $date = getdate( $timestamp );
        $this->Time = $date[ 'hours' ] * self::SECONDS_AN_HOUR +
                      $date[ 'minutes' ] * self::SECONDS_A_MINUTE +
                      $date[ 'seconds' ];
    }
561532
protected function getTime($timestamp): string
    {
        $toString = \str_replace(',', '.', (string) $timestamp);
        $parts = explode('.', $toString);

        return date('Y-m-d H:i:s', $parts[0]) . ($this->microtime && isset($parts[1]) ? ('.' . $parts[1]) : '');
    }
1087525
public function setLastVisit($timestamp = 'now')
	{
		$timestamp = new Date($timestamp);

		$query = $this->getQuery()
			->update($this->getTableName())
			->set(array('lastvisitDate' => $timestamp->toSql()))
			->whereEquals('id', $this->get('id'));

		return $query->execute();
	}
972539
protected function createDateTime($timeStamp)
    {
        $date = \DateTime::createFromFormat('U', $timeStamp);

        if ($tz = $this->getTimeZone()) {
            $date->setTimezone($tz);
        }

        return $date;
    }
534163
public static function getFormatedDate($timestamp)
    {
        return MTimestampHelper::getDay($timestamp) . "." . MTimestampHelper::getMonth($timestamp) . "." . MTimestampHelper::getYear($timestamp);
    }
905267
static function makeDateTime(int $timestamp) {
        $zone = new \DateTimeZone(\date_default_timezone_get());
        return (new \DateTime('@'.$timestamp))->setTimezone($zone);
    }