from unixtime to string '2017-01-01 12:00:00'
@param  string|int $timestamp
@return int        $timestamp
491413
static public function fromUnixtime($timestamp=null)
    {
        $timestamp || $timestamp = time();
        if(is_numeric($timestamp)) {
            // strftime format is different from date()
            //$value = strftime('%Y-%m-%d %H:%M:%S', $value);
            $timestamp = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
        }
        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;
    }
958408
static function IsDstNorthAmerica($timestamp = null)
	{
		if (!$timestamp) $timestamp = time();
		return $timestamp > self::DstStartNorthAmerica() && $timestamp < self::DstEndNorthAmerica();
	}
858109
public static function roundTimestampToDay($timestamp)
    {
        $day   = date('d', $timestamp);
        $month = date('m', $timestamp);
        $year  = date('Y', $timestamp);
        
        $roundedTimestamp = mktime(0, 0, 0, $month, $day, $year);
        
        return $roundedTimestamp;
    }
609621
public static function isTimestamp($tstamp)
    {
        return ((string)(int)$tstamp === $tstamp)
        && ($tstamp <= PHP_INT_MAX)
        && ($tstamp >= ~PHP_INT_MAX);
    }
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;
   }
1077590
public static function formatStartsAt($timestamp)
    {
        $tz = date_default_timezone_get();
        date_default_timezone_set('UTC');
        $date = date('c', $timestamp);
        date_default_timezone_set($tz);
        if (!$date) {
            throw new \RuntimeException(sprintf('Failed to format timestamp: %d', $timestamp));
        }

        return $date;
    }
838682
protected function createDateTime($timestamp)
    {
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($timestamp);
        $dateTime->setTimezone($this->dateTimeZone);

        return $dateTime;
    }
447204
public static function timestamp($timestamp = null)
    {
        if (!self::isDebug()) {
            return false;
        }

        $date = date(DATE_RFC822, $timestamp);
        return self::i()->dump($date, $timestamp . ' sec = ');
    }
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));
        }
    }
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);
        }
    }
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);
    }
1371418
protected function getJql($timestamp)
    {
        if (!isset($timestamp)) {
            return $this->jql;
        }

        return $this->jql . " AND updated > '" . date('Y-m-d H:i', $timestamp) . "'";
    }
489866
protected function hourCeil($timestamp)
    {
        return mktime(date('H', $timestamp) + 1, 0, 0, date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
    }
1248013
private static function getTimestamp($timestamp)
	{
		if ($timestamp instanceof DateTime) {
			$timestamp = $timestamp->getTimestamp();
		}
		
		if ((int)$timestamp != $timestamp) {
			throw new ResqueScheduler_InvalidTimestampException(
				'The supplied timestamp value could not be converted to an integer.'
			);
		}

		return (int)$timestamp;
	}
792256
public function calculate_expiry($timestamp) {
        $expiry = null;

        if (isset($this->expiredate)) {
            $expiry = $this->expiredate;
        } else if (isset($this->expireperiod)) {
            $expiry = $timestamp + $this->expireperiod;
        }

        return $expiry;
    }
787753
public static function isValidTimeStamp($timestamp)
    {
        return ((string) (integer) $timestamp === (string) $timestamp) && $timestamp <= PHP_INT_MAX && $timestamp >= ~PHP_INT_MAX;
    }