There are similar questions, but I couldn't find any pertaining to Doctrine2 configuration, so here goes...
I've read over this page describing timezones for Doctrine2, and I just want to clarify because it isn't clear how to actually use this: http://doctrine-orm.readthedocs.org/en/latest/cookbook/working-with-datetime.html
I want to store datetimes in UTC so that each user can have an associated timezone based on their location but the data is stored generically.
Basically, the data is the hours for a store (open at 9AM and close at 6PM for example). The store will keep track of its timezone so when a person at a store sets the "open" time, they are dealing with the store's timezone, the time gets converted to UTC and stored in the database. Next when a different user views the stores hours, they will see the open time in either their own timezone or the store timezone. It shouldn't matter because I have the times in UTC, so I can convert them to any timezone.
So the Doctrine docs show this example:
class UTCDateTimeType extends DateTimeType
{
// ...
}
But it doesn't say how to use it. Would I have to declare columns as "UTCDateTime" instead of "DateTime"? Where does this class need to live so that Doctrine is aware that the type exists?
I just found this part of a post about the Timestampable behavior that seems like a simpler solution:
config.yml
doctrine:
dbal:
types:
datetime: Acme\DoctrineExtensions\DBAL\Types\UTCDateTimeType
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With