Extends DateTimeType with support for time zones.
stringThe classname to use when creating objects.
stringThe DateTime format used when converting to string.
array|string|intThe locale-aware format marshal() uses when _useLocaleParser is true.
array<string>The DateTime formats allowed by marshal().
string|nullIdentifier name for this type
boolWhether marshal() should use locale-aware parser with _localeMarshalFormat.
DateTimeZone|nullDatabase time zone.
DateTimeZoneDefault time zone.
boolWhether database time zone is kept when converting
boolWhether we want to override the time of the converted Time objects so it points to the start of the day.
DateTimeZone|nullUser time zone.
Constructor
Converts a string into a DateTime object after parsing it using the locale aware parser with the format set by setLocaleFormat().
Converts a string into a DateTime object after parsing it using the formats in _marshalFormats.
Set the classname to use when building objects.
Returns the base type name that this class is inheriting.
Get the classname used for building objects.
Returns type identifier name for this object.
Returns an array of the values converted to the PHP representation of this type.
Convert request data into a datetime object.
Generate a new primary key value for a given type.
Set database timezone.
Set whether DateTime object created from database string is converted to default time zone.
Sets the locale-aware format used by marshal() when parsing strings.
Alias for setDatabaseTimezone().
Set user timezone.
Convert DateTime instance into strings.
Casts given value from a database type to a PHP equivalent.
Casts given value to Statement equivalent
Change the preferred class name to the FrozenTime implementation.
Sets whether to parse strings passed to marshal() using the locale-aware format set by setLocaleFormat().
Change the preferred class name to the mutable Time implementation.
__construct(string|null $name = null)
Constructor
string|null $name optional The name identifying this type
_parseLocaleValue(string $value): Cake\I18n\I18nDateTimeInterface|null
Converts a string into a DateTime object after parsing it using the locale aware parser with the format set by setLocaleFormat().
string $value The value to parse and convert to an object.
Cake\I18n\I18nDateTimeInterface|null_parseValue(string $value): DateTimeInterface|null
Converts a string into a DateTime object after parsing it using the formats in _marshalFormats.
string $value The value to parse and convert to an object.
DateTimeInterface|null_setClassName(string $class, string $fallback): void
Set the classname to use when building objects.
string $class The classname to use.
string $fallback The classname to use when the preferred class does not exist.
voidgetBaseType(): string|null
Returns the base type name that this class is inheriting.
This is useful when extending base type for adding extra functionality, but still want the rest of the framework to use the same assumptions it would do about the base type it inherits from.
string|nullgetDateTimeClassName(): string
Get the classname used for building objects.
stringgetName(): string|null
Returns type identifier name for this object.
string|nullmanyToPHP(array $values, array<string> $fields, Cake\Database\DriverInterface $driver): array<string, mixed>
Returns an array of the values converted to the PHP representation of this type.
array $values array<string> $fields Cake\Database\DriverInterface $driver array<string, mixed>marshal(mixed $value): DateTimeInterface|null
Convert request data into a datetime object.
Most useful for converting request data into PHP objects, that make sense for the rest of the ORM/Database layers.
mixed $value Request data
DateTimeInterface|nullnewId(): mixed
Generate a new primary key value for a given type.
This method can be used by types to create new primary key values when entities are inserted.
mixedsetDatabaseTimezone(DateTimeZone|string|null $timezone): $this
Set database timezone.
This is the time zone used when converting database strings to DateTime instances and converting DateTime instances to database strings.
DateTimeZone|string|null $timezone Database timezone.
$thissetKeepDatabaseTimezone(bool $keep): $this
Set whether DateTime object created from database string is converted to default time zone.
If your database date times are in a specific time zone that you want to keep in the DateTime instance then set this to true.
When false, datetime timezones are converted to default time zone. This is default behavior.
bool $keep If true, database time zone is kept when converting to DateTime instances.
$thissetLocaleFormat(array|string $format): $this
Sets the locale-aware format used by marshal() when parsing strings.
See Cake\I18n\Time::parseDateTime() for accepted formats.
array|string $format The locale-aware format
$thissetTimezone(DateTimeZone|string|null $timezone): $this
Alias for setDatabaseTimezone().
DateTimeZone|string|null $timezone Database timezone.
$thissetUserTimezone(DateTimeZone|string|null $timezone): $this
Set user timezone.
This is the time zone used when marshalling strings to DateTime instances.
DateTimeZone|string|null $timezone User timezone.
$thistoDatabase(mixed $value, Cake\Database\DriverInterface $driver): string|null
Convert DateTime instance into strings.
mixed $value The value to convert.
Cake\Database\DriverInterface $driver The driver instance to convert with.
string|nulltoPHP(mixed $value, Cake\Database\DriverInterface $driver): DateTimeInterface|null
Casts given value from a database type to a PHP equivalent.
mixed $value Value to be converted to PHP equivalent
Cake\Database\DriverInterface $driver Object from which database preferences and configuration will be extracted
DateTimeInterface|nulltoStatement(mixed $value, Cake\Database\DriverInterface $driver): mixed
Casts given value to Statement equivalent
mixed $value value to be converted to PDO statement
Cake\Database\DriverInterface $driver object from which database preferences and configuration will be extracted
mixeduseImmutable(): $this
Change the preferred class name to the FrozenTime implementation.
$thisuseLocaleParser(bool $enable = true): $this
Sets whether to parse strings passed to marshal() using the locale-aware format set by setLocaleFormat().
bool $enable optional Whether to enable
$thisuseMutable(): $this
Change the preferred class name to the mutable Time implementation.
$thisThe classname to use when creating objects.
stringThe DateTime format used when converting to string.
stringThe locale-aware format marshal() uses when _useLocaleParser is true.
See Cake\I18n\Time::parseDateTime() for accepted formats.
array|string|intThe DateTime formats allowed by marshal().
array<string>Identifier name for this type
string|nullWhether marshal() should use locale-aware parser with _localeMarshalFormat.
boolDatabase time zone.
DateTimeZone|nullDefault time zone.
DateTimeZoneWhether database time zone is kept when converting
boolWhether we want to override the time of the converted Time objects so it points to the start of the day.
This is primarily to avoid subclasses needing to re-implement the same functionality.
boolUser time zone.
DateTimeZone|null
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Database.Type.DateTimeTimezoneType.html