soomedia/doctrine-utcdatetime 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soomedia/doctrine-utcdatetime

Composer 安装命令:

composer require soomedia/doctrine-utcdatetime

包简介

Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone

README 文档

README

Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone.

All the code in this library was found in DoctrineExtensions' documentation. I take no credits for this code, I just simply bundled it in a nice and easy to use package.

Using the UTCDateTimeType

Add the library

Add the library in your project with Composer:

$ composer require soomedia/doctrine-utcdatetime

Override the default datetime type

Simply copied from DoctrineExtensions' documentation:

We simply have to register and override the datetime type. WARNING: this will override the datetime type for all your entities and for all entities in external bundles or extensions, so if you have some entities that require the standard datetime type from Doctrine, you must modify the above type and use a different name (such as utcdatetime). Additionally, if you use DoctrineExtensions, you'll need to modify Timestampable so that it includes utcdatetime as a valid type.

In Symfony2 you can do this like so:

doctrine:
    dbal:
        types:
            datetime: SooMedia\Doctrine\DBAL\Types\UTCDateTimeType

In Zend Framework 2 you have to add the following to your module.config.php:

<?php
return array(
    // other module config here
    'doctrine' => array(
        'configuration' => array(
            'orm_default' => array( // use the name of your default configuration/connection
                'types' => array(
                    'datetime' => 'SooMedia\Doctrine\DBAL\Types\UTCDateTimeType',
                ),
            ),
        ),
        // other configuration here, like the driver config
    ),
);

Credits

As I said: all credits for this piece of brilliant code goes to DoctrineExtensions. DoctrineExtensions adds a whole bunch of extra goodies to Doctrine, so I can really recommend using it!

统计信息

  • 总下载量: 7.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固