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′

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments