Returns the timestamp for the most recent (previous) occurance of [month].

@param	timestamp
@param	int			the month of year
@return	timestamp
197026
public static function previousMonth($ts = null, $month = sfTime::JANUARY)
	{
		// default to now
		if ($ts === null) $ts = sfDateTimeToolkit::now();
		
		// get offsets from january
		$offset1 = date('m', $ts);
		$offset2 = $month;
		
		// adjust if date wraps into last year
		$offset1 += $offset1 > $offset2 ? 0 : 12;
		
		return sfTime::subtractMonth($ts, $offset1 - $offset2);
	}
1318156
public static function ToDate($Timestamp = '') {
      if ($Timestamp == '')
         $Timestamp = time();
      elseif (!is_numeric($Timestamp))
         $Timestamp = self::ToTimestamp($Timestamp);

      return date('Y-m-d', $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;
    }
447204
public static function timestamp($timestamp = null)
    {
        if (!self::isDebug()) {
            return false;
        }

        $date = date(DATE_RFC822, $timestamp);
        return self::i()->dump($date, $timestamp . ' sec = ');
    }
553414
public static function getDelayedTimestampSize($timestamp)
	{
		$timestamp = self::toTimestamp($timestamp);
		return Resque::redis()->llen('delayed:' . $timestamp, $timestamp);
	}
255757
public static function friendly($timestamp)
    {
        $t = time() - $timestamp;
        $f = array(
            '31536000' => '年',
            '2592000' => '个月',
            '604800' => '周',
            '86400' => '天',
            '3600' => '小时',
            '60' => '分钟',
            '1' => '秒'
        );
        foreach ($f as $k => $v) {
            if (0 != $c = floor($t / (int)$k)) {
                return $c . $v . '前';
            }
        }
        return "刚刚";
    }
973003
public function getHour($timestamp = false)
    {
        if (!$timestamp) {
            $timestamp = $this->dateTime->getTimestamp();
        }

        return date('G', $timestamp);
    }
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));
    }
1098535
public function timeslice(int $timestamp = null):int{
		return (int)floor(($timestamp ?? time()) / $this->options->period);
	}
1149036
private function check_timestamp($timestamp)
    {
        if( ! $timestamp )
            throw new Exception(
                'Missing timestamp parameter. The parameter is required'
            );

        // verify that timestamp is recentish
        $now = time();
        if (abs($now - $timestamp) > $this->timestamp_threshold) {
            throw new Exception(
                "Expired timestamp, yours $timestamp, ours $now"
            );
        }
    }
70696
public static function elapsedTime($timestamp)
    {
        // @todo: deprecated - use timeDiff instead of this

        $dateDiff = self::timeDiff($timestamp);

        unset ($dateDiff['month']);

        $dateDiff['week'] = floor($dateDiff['days_total'] / 7);
        $dateDiff['day']  = $dateDiff['days_total'] % 7;

        return $dateDiff;
    }
868589
protected function getTstamp($time = null)
    {
        $time = !is_null($time) ? strtotime($time) : time();
        $month = date("M", $time);
        $day = substr("  " . date("j", $time), -2);
        $hhmmss = date("H:i:s", $time);
        return $month . " " . $day . " " . $hhmmss;
    }
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);
    }
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;
        }
    }
180155
public static function isTimestamp($timestamp)
    {
        if (is_bool($timestamp) || !is_scalar($timestamp)) {
            return false;
        }
        return ((string)(int)$timestamp === (string)$timestamp)
        && ($timestamp <= PHP_INT_MAX)
        && ($timestamp >= ~PHP_INT_MAX);
    }