class Date (View source)

The core parser for all Date content.

Properties

protected string|null $datestamp The input datestamp.
protected string|null $outputTimezone The desired output timezone.
protected string|null $createFromFormat The format used to assist date string parsing.
protected bool|DateTime $dateTime The resulting DateTime object.

Methods

__construct(string|null $datestamp = null, string|null $outputTimezone = 'UTC', string|null $createFromFormat = null)

Constructs a new instance of this class.

string
getDatestamp()

Get the input datestamp.

string
getOutputTimezone()

Get the requested output timezone.

string|null
getCreateFromFormat()

Get the format used to assist date string parsing.

DateTime|null
getDateTime()

Get the resulting DateTime object. If the date string could not be parsed, false will be returned.

Details

__construct(string|null $datestamp = null, string|null $outputTimezone = 'UTC', string|null $createFromFormat = null)

Constructs a new instance of this class.

Timezone calculation is performed on a best-effort basis and is not guaranteed. Factors which may affect the calculation include:

  • the version of glibc/musl that your OS relies on.
  • the freshness of the timestamp data your OS relies on.
  • the format of the datestamp inside of the feed and PHP's ability to parse it.

Parameters

string|null $datestamp The datestamp to handle, as a string. The default value is null.
string|null $outputTimezone The timezone identifier to use. Must be compatible with DateTimeZone. The default value is UTC.
string|null $createFromFormat Allows the user to assist the date parser by providing the input format of the datestamp. This will be passed into DateTime::createFromFormat() at parse-time.

See also

http://php.net/manual/en/datetime.createfromformat.php

string getDatestamp()

Get the input datestamp.

Return Value

string

string getOutputTimezone()

Get the requested output timezone.

Return Value

string

string|null getCreateFromFormat()

Get the format used to assist date string parsing.

Return Value

string|null

DateTime|null getDateTime()

Get the resulting DateTime object. If the date string could not be parsed, false will be returned.

Return Value

DateTime|null