MySQL data type / structure for storing timezone offsets

What would be the proper data type / structure for storing timezone offsets in MySQL? I just want to keep the numerical value (city and country are obviously stored in other columns).

Examples:

  • -5: 00 Guayaquil, ECU
  • -4: 30 Caracas, Vienna
  • 0:00 Some cities
  • 2:00 Bonn, GER
+6
source share
1 answer

You must use TIME . This is the right data type for the task: you have formatting and calculations . Moreover, according to the documents, TIME also supposed to be used as a result of the differences between the two points, which is actually Timezones.

From the docs:

MySQL retrieves and displays TIME values ​​in the format "HH: MM: SS" (or the Format "HHH: MM: SS" for a large clock). TIME values ​​can range from '-838: 59: 59' to '838: 59: 59'. The hourly part can be so large that the TIME type can be used not only to represent the time of day (which should be less than 24 hours), but also the elapsed time or time interval between two events (which can be much more than 24 hours or even negative).

+5
source

Source: https://habr.com/ru/post/898224/


All Articles