Different timezone_types on DateTime object

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.

Leave a Comment