I have a MySQL server that is in Europe/London
timezone and one of my table has a date field. The date is in Asia/Kathmandu
timezone. I want to write a select statement to get date field as unix timestamp. Something like SELECT UNIX_TIMESTAMP(FEILD_A)
but this will convert FIELD_A
to UTC assuming it as Europe/London
timezone which is the server's timezone. I want the query to treat the datetime as Asia/Kathmandu
timezone and return the timestamp.
Try this one
SELECT CONVERT_TZ(FEILD_A,'GMT','IST');
change IST to your timezone
FEILD_A should be date or timestamp.
Ref: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_convert-tz
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.