blue
blue

Reputation: 1795

Convert datetime in UTC format to GMT+7 in MySQL

I have a datetime column in MySQL table in Y-m-d H:i:s UTC format:

SELECT `transaction_time` FROM `transaction` LIMIT 1;
//2018-10-12 09:36:12

the above wil show my database record which i alreade save in UTC format, how can i show it in GMT+7 format ?

Upvotes: 2

Views: 6606

Answers (2)

Ruchira
Ruchira

Reputation: 145

You can use CONVERT_TZ() method.

Select CONVERT_TZ(`transaction_time`,'+00:00','+07:00') from `transaction` LIMIT 1;

Refer to this link

Upvotes: 1

Duy Anh Trần
Duy Anh Trần

Reputation: 36

You can use CONVERT_TZ() function:

SELECT CONVERT_TZ(transaction_time, '+00:00', '+07:00') FROM transaction LIMIT 1;

You can read more about CONVERT_TZ() function here.

Upvotes: 0

Related Questions