2

what's the best way to store information about timezone in mysql database? I don't have any information about a time, only timezone, for instance: +02.00, -03.00 etc. Do you think that varchar (6) will be correct?

Marcin Erbel
  • 1,597
  • 6
  • 32
  • 51
  • thanks, I will read this. I'm sorry that I didn't find it earlier. – Marcin Erbel Jun 12 '13 at 11:37
  • 1
    You don't have a *time zone*. You have a *time zone offset*. An offset is usually not useful in isolation. Please read "Time Zone != Offset" in the [timezone tag wiki](http://stackoverflow.com/tags/timezone/info). – Matt Johnson-Pint Jun 12 '13 at 15:40

2 Answers2

5

VARCHAR(6) is fine, but personally, i would store the offset using a signed SMALLINT (in minutes).

Like this, you can store numbers from -32768 to 32767.

You could also store it as TINYINT if you just want to store the hours-offset. (from -128 to 127)

Stefan
  • 2,028
  • 2
  • 36
  • 53
1

its all depends upon on you, but Varchar works for you.

decimal(2,2)

also works fine for storing time zone. For other Date related data types are as follows

Data Type

1-time

2-timestamp

3-date

4-datetime

KhAn SaAb
  • 5,248
  • 5
  • 31
  • 52