Documentation

CastDate extends Cast
in package

Cast dates from valid sources.

Timezone behaviours:

  • 'default' retains the TZ of a given value and only applies the system TZ if one is absent (strings, numbers).

  • 'system' sets the TZ to the system TZ, always.

  • 'utc' sets the TZ to UTC, always.

  • sets the TZ to the given ISO name, e.g. 'Europe/London'.

Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY

Table of Contents

Properties

$timezone  : string
$nullable  : bool
$property  : string
$target  : object

Methods

__construct()  : void
build()  : mixed
Build a value.
find()  : null|static
Find a cast attribute on a property.
isNullable()  : bool
Is this property nullable?
parse()  : array<string, static>
Find all cast attributes on a target object.

Properties

$timezone

public string $timezone = 'default'

$nullable

protected bool $nullable = false

$property

protected string $property

$target

protected object $target

Methods

__construct()

public __construct([string $timezone = 'default' ]) : void
Parameters
$timezone : string = 'default'

default|system|utc|

build()

Build a value.

public build(mixed $value) : mixed
Parameters
$value : mixed
Tags
inheritdoc

find()

Find a cast attribute on a property.

public static find(object $target, ReflectionProperty|string $property) : null|static
Parameters
$target : object
$property : ReflectionProperty|string
Return values
null|static

isNullable()

Is this property nullable?

public isNullable() : bool
Return values
bool

parse()

Find all cast attributes on a target object.

public static parse(object $target) : array<string, static>
Parameters
$target : object
Return values
array<string, static> —

[ property => virtual ]

On this page

Search results