Giter VIP home page Giter VIP logo

doctrine-utcdatetime's Introduction

Doctrine UTCDateTimeType

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!

doctrine-utcdatetime's People

Contributors

raphhh avatar willemo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.