trait DateTrait (View source)

Shared code for working with elements which manage dates.

Properties

protected string $createFromFormat The format that should be used when determining how to parse a date from a date string.
protected string $outputTimezone The preferred timezone to use for date output.

Methods

setDateFormat(string $createFromFormat)

Allows the user to help the date parser by providing the format of the datestamp in the feed.

setOutputTimezone(string $timezone = 'UTC')

Set the preferred output timezone.

Details

DateTrait setDateFormat(string $createFromFormat)

Allows the user to help the date parser by providing the format of the datestamp in the feed.

This will be passed into DateTime::createFromFormat() at parse-time.

Parameters

string $createFromFormat The format of the datestamp in the feed.

Return Value

DateTrait

See also

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

DateTrait setOutputTimezone(string $timezone = 'UTC')

Set the preferred output timezone.

This 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 $timezone The timezone identifier to use. Must be compatible with DateTimeZone. The default value is UTC.

Return Value

DateTrait