This documentation describes unreleased changes on the main branch.

DateTimeField

Class. It extends Field.

use Saij\WpAppFramework\Query\Field\DateTimeField;

A time column of a table (DateTimeImmutable), stored in UTC to the second; times of other time zones are converted before they are compared. Meta fields have no time type.

Constructor

new DateTimeField(string $class, string $field)
ParameterTypeDefaultDescription
classclass-stringrequiredThe class the field belongs to: a meta class (#[PostMeta]) or row class (#[Table]).
fieldstringrequiredThe name of the constructor parameter.

Methods

between()

between(DateTimeInterface $min, DateTimeInterface $max): Condition

Matches times from $min to $max, both included.

ParameterTypeDefaultDescription
minDateTimeInterfacerequiredThe earliest time, in any time zone.
maxDateTimeInterfacerequiredThe latest time, in any time zone.

Returns Condition

equals()

equals(DateTimeInterface $value): Condition

Matches times equal to $value.

ParameterTypeDefaultDescription
valueDateTimeInterfacerequiredThe time to compare with, in any time zone; compared to the second.

Returns Condition

getClass()

getClass(): string

The class the field belongs to.

Returns class-string

getField()

getField(): string

The name of the field: the name of the constructor parameter.

Returns string

greaterOrEqual()

greaterOrEqual(DateTimeInterface $value): Condition

Matches times at or after $value.

ParameterTypeDefaultDescription
valueDateTimeInterfacerequiredThe time to compare with, in any time zone; compared to the second.

Returns Condition

greaterThan()

greaterThan(DateTimeInterface $value): Condition

Matches times after $value.

ParameterTypeDefaultDescription
valueDateTimeInterfacerequiredThe time to compare with, in any time zone; compared to the second.

Returns Condition

in()

in(DateTimeInterface ...$values): Condition

Matches times equal to one of $values. Throws an InvalidArgumentException if no value is given.

ParameterTypeDefaultDescription
...valuesDateTimeInterfaceThe times to compare with, in any time zone; compared to the second.

Returns Condition

lessOrEqual()

lessOrEqual(DateTimeInterface $value): Condition

Matches times at or before $value.

ParameterTypeDefaultDescription
valueDateTimeInterfacerequiredThe time to compare with, in any time zone; compared to the second.

Returns Condition

lessThan()

lessThan(DateTimeInterface $value): Condition

Matches times before $value.

ParameterTypeDefaultDescription
valueDateTimeInterfacerequiredThe time to compare with, in any time zone; compared to the second.

Returns Condition

notEquals()

notEquals(DateTimeInterface $value): Condition

Matches times not equal to $value. On a nullable column, rows whose column is null match as well.

ParameterTypeDefaultDescription
valueDateTimeInterfacerequiredThe time to compare with, in any time zone; compared to the second.

Returns Condition

notIn()

notIn(DateTimeInterface ...$values): Condition

Matches times equal to none of $values. On a nullable column, rows whose column is null match as well. Throws an InvalidArgumentException if no value is given.

ParameterTypeDefaultDescription
...valuesDateTimeInterfaceThe times to compare with, in any time zone; compared to the second.

Returns Condition