adrenalinkin / doctrine-utc-date-time
提供Doctrine DBAL日期和时间类型,用于以UTC格式存储到数据库中
v2.0.0
2022-08-21 18:32 UTC
Requires
- php: ^7.1 || ^8.0
- doctrine/dbal: ^2.7 || ^3.0
Requires (Dev)
- phpunit/phpunit: ^7.0 || ^8.0 || ^9.0
README
介绍
组件包含DBAL
日期和时间类型,可以作为Doctrine
类型注册。这些类型提供了在UTC中存储日期和时间的功能。以下是可用的类型列表:
安装
打开命令行控制台,进入您的项目目录,并执行以下命令以下载此组件的最新稳定版本:
composer require adrenalinkin/doctrine-utc-date-time
此命令要求您全局安装Composer。
用法
要注册新的Doctrine
类型,请使用官方说明如何使用Doctrine DBAL。
注册新的单独UTC类型
# app/config/config.yml doctrine: dbal: types: utc_date: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateType utc_datetime: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateTimeType utc_time: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcTimeType
此外,您还可以覆盖标准类型
# app/config/config.yml doctrine: dbal: types: date: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateType datetime: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateTimeType time: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcTimeType