How to get time zone offset in MySQL?

Hello everyone.

Recently, while working on a project, I needed the time zone offset. I could have calculated the time zone offset in PHP, but I thought it would be easier and more advantageous to find it in MySQL. So, I created a query that calculates the time zone offset and will share it with you.

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

The result will be as follows;

’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