timezone_type attribute of the Datetime class

Asked

Viewed 55 times

0

I would like to know what kind of values the attribute timezone_type can receive. From what I understand he can receive the numbers 1, 2 and 3. But what is the difference between each of these values that the attribute timezone_type can receive.

 object(DateTime)[3]
      public 'date' => string '2020-09-30 14:32:03.661324' (length=26)
      public 'timezone_type' => int 3
      public 'timezone' => string 'America/Sao_Paulo' (length=17)
  • related: https://stackoverflow.com/questions/17694894/different-timezone-types-on-datetime-object

1 answer

1


The three different types of Datetime objects:

Type 1 - UTC offset

UTC compensation is the difference in hours and minutes of Coordinated Universal Time (UTC) for a given location and date.

new DateTime("17 July 2013 -0300");

Type 2 - Timezone abbreviation

Greenwich Mean Time (TMG) or Greenwich Mean Time (GMT) is the apparent solar time at the Royal Observatory in Greenwich, London.

new DateTime("17 July 2013 GMT");

Type 3 - Dentifier Timezone Which is the way out of your var_dump(), in the body of the question, is type 3. The time zone identifier, such as UTC or America/Sao_paulo. The list of valid identifiers is available in the php.net documentation. List of Supported Time Zones

new DateTime( "17 July 2013", new DateTimeZone("Europe/London"));

More on the issue in English: https://stackoverflow.com/questions/17694894/different-timezone-types-on-datetime-object

Browser other questions tagged

You are not signed in. Login or sign up in order to post.