HumHub Documentation (unofficial)

AbstractDate
in package
implements HeaderInterface

AbstractYes

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

Tags
see
Date
see
Expires
see
IfModifiedSince
see
IfUnmodifiedSince
see
LastModified

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

Table of Contents

Interfaces

HeaderInterface
Interface for HTTP Header classes.

Constants

DATE_ANSIC  = 2
DATE_RFC1036  = 1
DATE_RFC1123  = 0
Date formats according to RFC 2616

Properties

$date  : DateTime
Date instance for this header
$dateFormat  : string
Date output format
$dateFormats  : array<string|int, mixed>
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

Methods

__toString()  : string
Allow casting to string
compareTo()  : int
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.
date()  : DateTime
Return date for this header as an instance of \DateTime
fromString()  : static
Create date-based header from string
fromTimestamp()  : static
Create date-based header from Unix timestamp
fromTimeString()  : static
Create date-based header from strtotime()-compatible string
getDate()  : string
Return date for this header
getDateFormat()  : string
Return current date output format
getFieldValue()  : string
Get header value as formatted date
setDate()  : $this
Set the date for this header, this can be a string or an instance of \DateTime
setDateFormat()  : mixed
Set date output format
toString()  : string
Return header line

Constants

Properties

$date

Date instance for this header

protected DateTime $date

$dateFormat

Date output format

protected static string $dateFormat = 'D, d M Y H:i:s \G\M\T'

$dateFormats

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

protected static array<string|int, mixed> $dateFormats = [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']
Tags
link
http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3

Methods

__toString()

Allow casting to string

public __toString() : string
Return values
string

compareTo()

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.

public compareTo(string|DateTime $date) : int
Parameters
$date : string|DateTime
Tags
see
strcmp()
throws
InvalidArgumentException
Return values
int

date()

Return date for this header as an instance of \DateTime

public date() : DateTime
Return values
DateTime

fromString()

Create date-based header from string

public static fromString(string $headerLine) : static
Parameters
$headerLine : string
Tags
throws
InvalidArgumentException
Return values
static

fromTimestamp()

Create date-based header from Unix timestamp

public static fromTimestamp(int $time) : static
Parameters
$time : int
Tags
throws
InvalidArgumentException
Return values
static

fromTimeString()

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

public static fromTimeString(int|string $time) : static
Parameters
$time : int|string
Tags
throws
InvalidArgumentException
Return values
static

getDate()

Return date for this header

public getDate() : string
Return values
string

getDateFormat()

Return current date output format

public static getDateFormat() : string
Return values
string

getFieldValue()

Get header value as formatted date

public getFieldValue() : string
Return values
string

setDate()

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

public setDate(string|DateTime $date) : $this
Parameters
$date : string|DateTime
Tags
throws
InvalidArgumentException
Return values
$this

toString()

Return header line

public toString() : string
Return values
string

        
On this page

Search results