Different timezone_types on DateTime object

I know this is an ancient post, but since Doctrine was mentioned, I feel the need to share what I've recently experienced regarding this issue.

@vascowhite is correct, but regarding Doctrine (at least on my configuration) dates sent to the server (e.g. to save) via HTTP are converted timezone type 2. Doctrine handles them properly and saves the date correctly, but it does not convert the timezone type.

If you are performing a "save and and return fresh values" type operation, note that Doctrine will use the cached value (with timezone_type 2). This becomes important when you are expecting timezone_type 3 as you would normally get during a page reload. We have a custom date converter JS class that expects timezone_type 3 and it was unable to convert it. Admittedly, the date converter should account for this, but also one should be aware that the timezone type will be the last loaded value in Doctrine. Clearing Doctrine's cache after saving will force the data to reload with timezone_type 3.


Timezones can be one of three different types in DateTime objects:

  • Type 1; A UTC offset, such as in new DateTime("17 July 2013 -0300");
  • Type 2; A timezone abbreviation, such as in new DateTime("17 July 2013 GMT");
  • Type 3: A timezone identifier, such as in new DateTime( "17 July 2013", new DateTimeZone("Europe/London"));

Only DateTime objects with type 3 timezones attached will allow for DST correctly.

In order to always have type 3 you will need to store the timezone in your database as accepted identifiers from this list and apply it to your DateTime object on instantiation.