Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL-921: [GH-616] Always store dates in UTC #2163

Closed
doctrinebot opened this issue Jun 11, 2014 · 3 comments
Closed

DBAL-921: [GH-616] Always store dates in UTC #2163

doctrinebot opened this issue Jun 11, 2014 · 3 comments
Assignees
Labels

Comments

@doctrinebot
Copy link

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of LinusU:

Url: #616

Message:

This PQ will make sure that the dates saved in the database (without indication of timezone) is always stored in the UTC timezone.

I was doing development on my machine in Sweden when I noticed that when I created a DateTime, stored it in the db and then retrieved it again, the time was off by two hours. This is because a created the DateTime object with the UTC timezone. Doctrine then saved it straight to the database (by using $date->format(...)) and thus the information about which timezone it was in was lost. When doctrine then fetched the value, it used DateTime::createFromFormat(...) to create a DateTime for me. The problem is that since the timezone wasn't saved anywhere, it assumed that it was a Swedish date, and thus it removed two hours.

I believe that the correct way of doing it is to store the dates in the db as UTC. Then it will always work no matter what the default timezone is, even if I later decide to change it.

date*default_timezone*set('UTC') is not the answer. If I use it, I need to make sure that every DateTime that I pass to doctrine always has the timezone set to UTC. Since the DateTime can come from any number of sources (e.g. third party library) it could easily introduce hard to detect bugs. It will also output every date in the UTC timezone which may not be what I want if I'm developing a localised site (e.g. small page for a local Swedish business).

@doctrinebot
Copy link
Author

Comment created by @doctrinebot:

A related Github Pull-Request [GH-616] was closed:
#616

@doctrinebot
Copy link
Author

Issue was closed with resolution "Won't Fix"

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants