Abstract Date/Time Header Supports headers that have date/time as value

see
see
see
see
see Note for 'Location' header: While RFC 1945 requires an absolute URI, most of the browsers also support relative URI This class allows relative URIs, and let user retrieve URI instance if strict validation needed
package Default

 Methods

Allow casting to string

__toString() : string

Returns

string

Compare provided date to date for this header Returns < 0 if date in header is less than $date; > 0 if it's greater, and 0 if they are equal.

compareTo(string|\DateTime $date) : integer
see

Parameters

$date

string\DateTime

Exceptions

\Zend\Http\Header\Exception\InvalidArgumentException

Returns

integer

Return date for this header as an instance of \DateTime

date() : \DateTime

Returns

\DateTime

Create date-based header from string

fromString(string $headerLine) : \Zend\Http\Header\AbstractDate
Static
inherited_from \Zend\Http\Header\HeaderInterface::fromString()

Parameters

$headerLine

string

Exceptions

\Zend\Http\Header\Exception\InvalidArgumentException

Returns

\Zend\Http\Header\AbstractDate

Create date-based header from strtotime()-compatible string

fromTimeString(integer|string $time) : \Zend\Http\Header\AbstractDate
Static
fluent This method is part of a fluent interface and will return the same instance

Parameters

$time

integerstring

Exceptions

\Zend\Http\Header\Exception\InvalidArgumentException

Returns

\Zend\Http\Header\AbstractDate

Create date-based header from Unix timestamp

fromTimestamp(integer $time) : \Zend\Http\Header\AbstractDate
Static
fluent This method is part of a fluent interface and will return the same instance

Parameters

$time

integer

Exceptions

\Zend\Http\Header\Exception\InvalidArgumentException

Returns

\Zend\Http\Header\AbstractDate

Return date for this header

getDate() : string

Returns

string

Return current date output format

getDateFormat() : string
Static

Returns

string

Get header value as formatted date

getFieldValue() : string
inherited_from \Zend\Http\Header\HeaderInterface::getFieldValue()

Returns

string

Set the date for this header, this can be a string or an instance of \DateTime

setDate(string|\DateTime $date) : \Zend\Http\Header\AbstractDate

Parameters

$date

string\DateTime

Exceptions

\Zend\Http\Header\Exception\InvalidArgumentException

Returns

\Zend\Http\Header\AbstractDate

Set date output format

setDateFormat(integer $format) 
Static

Parameters

$format

integer

Exceptions

\Zend\Http\Header\Exception\InvalidArgumentException

Return header line

toString() : string

Returns in form of "NAME: VALUE"

inherited_from \Zend\Http\Header\HeaderInterface::toString()

Returns

string

 Properties

 

Date instance for this header

$date : \DateTime

Default

null
 

Date output format

$dateFormat : string

Default

'D, d M Y H:i:s \G\M\T'
Static
 

Date formats defined by RFC 2616. RFC 1123 date is required RFC 1036 and ANSI C formats are provided for compatibility with old servers/clients

$dateFormats : array

Default

array(self::DATE_RFC1123 => 'D, d M Y H:i:s \G\M\T', self::DATE_RFC1036 => 'D, d M y H:i:s \G\M\T', self::DATE_ANSIC => 'D M j H:i:s Y')
Static

 Constants

 

DATE_ANSIC

DATE_ANSIC = 2 
 

DATE_RFC1036

DATE_RFC1036 = 1 
 

Date formats according to RFC 2616

DATE_RFC1123 = 0