DDC-523: Tell Doctrine2 to force a timezone for a date or datetime column #650

Closed
opened 2026-01-22 12:45:39 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 15, 2010).

Jira issue originally created by user ssurowiec:

I'm working on a project that will live on multiple servers in multiple time zones and it would be great if I could tell Doctrine2, either through mappings or some other means, that all dates going into the DB should be normalized to a given time zone (such as GMT) and then be changed back to the servers local time on select. This can be accomplished using events right now but might be useful for other people in the same boat as me.

Originally created by @doctrinebot on GitHub (Apr 15, 2010). Jira issue originally created by user ssurowiec: I'm working on a project that will live on multiple servers in multiple time zones and it would be great if I could tell Doctrine2, either through mappings or some other means, that all dates going into the DB should be normalized to a given time zone (such as GMT) and then be changed back to the servers local time on select. This can be accomplished using events right now but might be useful for other people in the same boat as me.
admin added the New Feature label 2026-01-22 12:45:39 +01:00
admin closed this issue 2026-01-22 12:45:39 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 15, 2010):

Comment created by ssurowiec:

Attached is a sample DateTimeType class I modified to do this. This is a quick, dirty, solution but illustrates the idea.

@doctrinebot commented on GitHub (Apr 15, 2010): Comment created by ssurowiec: Attached is a sample DateTimeType class I modified to do this. This is a quick, dirty, solution but illustrates the idea.
Author
Owner

@doctrinebot commented on GitHub (Apr 16, 2010):

Comment created by @beberlei:

We won't change the current behaviour since its the 95% use-case.

In your case, you could either:

  1. set the timezone on all servers to GMT/UTC using the PHP Ini variable "date.timezone"
  2. Implement your own DateTime types on top of the existing ones
  3. Use a Database that can handle timezones correctly (Postgresql)
@doctrinebot commented on GitHub (Apr 16, 2010): Comment created by @beberlei: We won't change the current behaviour since its the 95% use-case. In your case, you could either: 1. set the timezone on all servers to GMT/UTC using the PHP Ini variable "date.timezone" 2. Implement your own DateTime types on top of the existing ones 3. Use a Database that can handle timezones correctly (Postgresql)
Author
Owner

@doctrinebot commented on GitHub (Apr 16, 2010):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Apr 16, 2010): Issue was closed with resolution "Won't Fix"
Author
Owner

@doctrinebot commented on GitHub (Apr 10, 2012):

Comment created by bschussek:

Benjamin, could you give more information about the 95%? I'm trying to understand this issue a bit better, but fail to see the many use cases for the current behavior.

@doctrinebot commented on GitHub (Apr 10, 2012): Comment created by bschussek: Benjamin, could you give more information about the 95%? I'm trying to understand this issue a bit better, but fail to see the many use cases for the current behavior.
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/ce8e3a72a5d7e9bc732c

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/ce8e3a72a5d7e9bc732c - [10571_DateTimeType.php](https://gist.github.com/ce8e3a72a5d7e9bc732c#file-10571_DateTimeType-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#650