Detect if a date is in Daylight saving time in MySql

前端 未结 4 665
失恋的感觉
失恋的感觉 2021-01-25 09:32

I have inherited a legacy application where all the dates and times are stored in the local timezone (UK). I am not in a position to change how these are stored.

Howeve

4条回答
  •  感动是毒
    2021-01-25 10:22

    Timezones are not stored in DATETIME values. Interestingly, they are for TIMESTAMPs.

    Given a stored date, you can posthumously figure out if DST was "on" at that time based on the local rules. Since you can't change the dates, I would guess that you can't add a column to store the timezone...

    Make a stored procedure that contains the rules and converts a given date to GMT.

    Note that only the people that live around Greenwich want their times displayed in GMT. :)

    Good luck.

提交回复
热议问题