DATETIME VS INT for storing time?

后端 未结 2 2051
南笙
南笙 2021-01-11 16:43

Which one is best to use, DateTime or INT (Unix Timestamp) or anything else to store the time value?

I think INT will be better at performance and also more universa

2条回答
  •  半阙折子戏
    2021-01-11 17:25

    Changing the client time zone The server interprets TIMESTAMP values in the client’s current time zone, not its own. Clients in different time zones should set their zone so that the server can properly interpret TIMESTAMP values for them.

    And if you want to get the time zone that a certain one you can do this:

    CONVERT_TZ(@dt,'US/Central','Europe/Berlin') AS Berlin,
    

    I wouldn't store it in int, you should check out MySQL Cookbook by Paul DuBois he covers lot's of things in it.Also there is a big portion about your quetion.

提交回复
热议问题