0 follower

Final Class Yiisoft\Db\Expression\Value\DateTimeValue

InheritanceYiisoft\Db\Expression\Value\DateTimeValue
ImplementsYiisoft\Db\Expression\ExpressionInterface

Represents a value that should be treated as a date and time value for specific column type.

Psalm Types

Name Value
SupportedColumnType \Yiisoft\Db\Constant\ColumnType::DATE|\Yiisoft\Db\Constant\ColumnType::DATETIME|\Yiisoft\Db\Constant\ColumnType::DATETIMETZ|\Yiisoft\Db\Constant\ColumnType::TIME|\Yiisoft\Db\Constant\ColumnType::TIMETZ|\Yiisoft\Db\Constant\ColumnType::TIMESTAMP|\Yiisoft\Db\Constant\ColumnType::BIGINT|\Yiisoft\Db\Constant\ColumnType::INTEGER|\Yiisoft\Db\Constant\ColumnType::FLOAT|\Yiisoft\Db\Constant\ColumnType::DOUBLE|\Yiisoft\Db\Constant\ColumnType::DECIMAL

Constants

Hide inherited constants

Constant Value Description Defined By
SUPPORTED_TYPES [ \Yiisoft\Db\Constant\ColumnType::DATE => true, \Yiisoft\Db\Constant\ColumnType::DATETIME => true, \Yiisoft\Db\Constant\ColumnType::DATETIMETZ => true, \Yiisoft\Db\Constant\ColumnType::TIME => true, \Yiisoft\Db\Constant\ColumnType::TIMETZ => true, \Yiisoft\Db\Constant\ColumnType::TIMESTAMP => true, \Yiisoft\Db\Constant\ColumnType::BIGINT => true, \Yiisoft\Db\Constant\ColumnType::INTEGER => true, \Yiisoft\Db\Constant\ColumnType::FLOAT => true, \Yiisoft\Db\Constant\ColumnType::DOUBLE => true, \Yiisoft\Db\Constant\ColumnType::DECIMAL => true, ] Yiisoft\Db\Expression\Value\DateTimeValue

Property Details

Hide inherited properties

$info public property
public array $info = []
$type public property
public string $type ColumnType::DATETIMETZ
$value public property
public integer|float|string|\Stringable|DateTimeInterface $value null

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( DateTimeInterface|float|integer|string|\Stringable $value, string $type ColumnType::DATETIMETZ, array $info = [] )
$value DateTimeInterface|float|integer|string|\Stringable

The value to be treated as a date and time value.

$type string

The column type. The following types are supported:

  • {@see \Yiisoft\Db\Constant\ColumnType::DATE}
  • {@see \Yiisoft\Db\Constant\ColumnType::DATETIME}
  • {@see \Yiisoft\Db\Constant\ColumnType::DATETIMETZ}
  • {@see \Yiisoft\Db\Constant\ColumnType::TIME}
  • {@see \Yiisoft\Db\Constant\ColumnType::TIMETZ}
  • {@see \Yiisoft\Db\Constant\ColumnType::TIMESTAMP}
  • {@see \Yiisoft\Db\Constant\ColumnType::BIGINT}
  • {@see \Yiisoft\Db\Constant\ColumnType::INTEGER}
  • {@see \Yiisoft\Db\Constant\ColumnType::FLOAT}
  • {@see \Yiisoft\Db\Constant\ColumnType::DOUBLE}
  • {@see \Yiisoft\Db\Constant\ColumnType::DECIMAL}
$info array

Additional information about {@see \Yiisoft\Db\Schema\Column\ColumnInterface the column}.

                public function __construct(
    public readonly int|float|string|Stringable|DateTimeInterface $value,
    public readonly string $type = ColumnType::DATETIMETZ,
    public readonly array $info = [],
) {
    if (!isset(self::SUPPORTED_TYPES[$type])) {
        throw new InvalidArgumentException("The type '$type' is not supported by DateTimeValue.");
    }
}