Posts

How to get timezone offset on MySQL?

Hello to everyone.

When I was working recently, I needed a timezone offset on one subject. I could calculate timezone offset on php but I thought it would be easier and more advantageous to find it on MySQL. So I created a query that calculates the timezone offset and I will share it with you.

SELECT TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), 'Asia/Kathmandu', 'UTC')), '%H:%i') as offset;

Result will be;

’05:45′