sfWebResponse::getDate PHP Method

getDate() public static method

Retrieves a formated date.
public static getDate ( string $timestamp, string $type = 'rfc1123' ) : string
$timestamp string Timestamp
$type string Format type
return string Formatted date
    public static function getDate($timestamp, $type = 'rfc1123')
    {
        $type = strtolower($type);
        if ($type == 'rfc1123') {
            return substr(gmdate('r', $timestamp), 0, -5) . 'GMT';
        } else {
            if ($type == 'rfc1036') {
                return gmdate('l, d-M-y H:i:s ', $timestamp) . 'GMT';
            } else {
                if ($type == 'asctime') {
                    return gmdate('D M j H:i:s', $timestamp);
                } else {
                    throw new InvalidArgumentException('The second getDate() method parameter must be one of: rfc1123, rfc1036 or asctime.');
                }
            }
        }
    }

Usage Example

コード例 #1
0
 public function execute($request)
 {
     $css = Doctrine::getTable('SnsConfig')->get('customizing_css', '');
     $this->getResponse()->setContent($css);
     $this->getResponse()->setContentType('text/css');
     // cache
     $filesystem = new sfFilesystem();
     $dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css';
     @$filesystem->mkdirs($dir);
     file_put_contents($dir . DIRECTORY_SEPARATOR . 'customizing.css', $css);
     $this->getResponse()->setHttpHeader('Last-Modified', sfWebResponse::getDate(time()));
     return sfView::NONE;
 }
All Usage Examples Of sfWebResponse::getDate