org_heigl / pdo_timezone_helper
数据库时区处理助手
dev-master
2016-09-30 18:51 UTC
Requires (Dev)
- phpunit/dbunit: ^2.0
- phpunit/phpunit: ^5.5
This package is auto-updated.
Last update: 2024-08-29 03:58:10 UTC
README
一个简化PDO中时区处理的库
使用方法
此库提供了一个助手,用于生成特定数据库的代码,从日期时间条目和时区条目获取UTC日期时间。
您可以在数据库中存储带有时区偏移或不带偏移的日期时间,但必须包含时区,此助手将从这些数据创建UTC日期时间以进行比较
$helper = new PdoTimezoneHelper::create($pdoObject); $helper->setTimezoneField($field); echo sprintf( "SELECT * FROM table WHERE %1$s < '2016-12-31T23:59:59'", $helper->getUtcDateTime($dateTimeField);
安装
建议使用 Composer 安装此库
composer require org_heigl/pdo_timezone_helper