Generate an etag based on the timestamp and the current user.

@param \DateTime $timeStamp

@return string The generated etag.
420561
protected function generateEtag(\DateTime $timeStamp)
    {
        $user = $this->securityService->findGitUser();
        $userString = '';
        if (null !== $user) {
            $userString = $user->getGitUserName();
        }

        return md5($timeStamp->getTimestamp() . $userString);
    }
771243
public function fromRedisTimestamp($timestamp) : DateTime
    {
        $date = DateTime::createFromFormat('U', $timestamp);
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
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;
	}
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);
        }
    }
473143
static function createDateTimeClass($datetime = '')
    {
        if (preg_match("/^\d+$/", trim($datetime))) return new \DateTime("@{$datetime}");
        if (!$timestamp = strtotime($datetime)) return false;
        return new \DateTime("@{$timestamp}");
    }
561910
public function getGMTMidnightTstamp(int $tstamp)
    {
        $date = new \DateTime(date('Y-m-d', $tstamp));
        $date->setTimezone(new \DateTimeZone('GMT'));
        $date->setTime(0, 0, 0);

        return $date->getTimestamp();
    }
553414
public static function getDelayedTimestampSize($timestamp)
	{
		$timestamp = self::toTimestamp($timestamp);
		return Resque::redis()->llen('delayed:' . $timestamp, $timestamp);
	}
952576
public static function parse($timestamp = null)
    {
        if (static::isMilliseconds($timestamp)) {
            return static::fromMilliseconds($timestamp);
        }

        if ($timestamp instanceof Carbon) {
            return $timestamp;
        }

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

        return $dateTime;
    }
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]";
        }
    }
973003
public function getHour($timestamp = false)
    {
        if (!$timestamp) {
            $timestamp = $this->dateTime->getTimestamp();
        }

        return date('G', $timestamp);
    }
1100084
public function getRelativeDateTime($timestamp, $ending = true)
    {
        if (! $timestamp) {
            return 'N/A';
        }
        
        if (! is_numeric($timestamp)) {
            $timestamp = (int) strtotime($timestamp);
        }
        
        if ($timestamp == '0') {
            return 'N/A';
        }
        
        $this->relative_config['suffix'] = true;
        if (! $ending) {
            $this->relative_config['suffix'] = false;
        }
        
        $relative = new RelativeTime($this->relative_config);
        return $relative->timeAgo($timestamp);
    }
254193
public static function create(float $timestamp = null): \DateTime
    {
        $date = static::format($timestamp);
        return new \DateTime($date);
    }
837675
public static function longDate($timestamp = null)
    {
        $l = self::getLocale();
        return self::date($l->shortDateTime, $timestamp);
    }
1182747
public static function unix2dos($timestamp = 0)
    {
        $timestamp = ! $timestamp ? 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);
    }
341032
public static function fromTimestamp($timestamp)
    {
        try {
            $dateTime = new DateTime("@{$timestamp}");

            return static::fromDateTime($dateTime);
        } catch (Exception $e) {
            throw new InvalidArgumentValue('$timestamp', $timestamp, __CLASS__, $e);
        }
    }
1235401
private function getNewDateFileName($timestamp)
    {
        $this->currentFileDateTime = $timestamp;
        $this->currentFileIndex = 0;
        $this->currentNoIndexFileName = $this->replaceDateTime($this->fileName, $timestamp);
        $this->currentFileExt = pathinfo($this->currentNoIndexFileName, PATHINFO_EXTENSION);
        return $this->currentNoIndexFileName = substr($this->currentNoIndexFileName, 0, -strlen($this->currentFileExt));
    }