How to calculate MySQL timezone offset

Sometimes it is necessary to calculate the offset for the current timezone. Therefore you can use this helpful snippet:

SET @tzOffset = (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(CONVERT_TZ(NOW(), 'Etc/UTC', 'Europe/Berlin')));

That’s it.

Posted in