Categories
MySQL Server

MySQL Convert UTC Timestamp to Specific Timezone

MySQL example to convert UTC timestamp to specific timezone.

SELECT 
  SensorName, 
  MAX(CONVERT_TZ(LastUpdated, 'UTC', 'Europe/Amsterdam')) AS LastUpdated
FROM Sensors 
WHERE (TIME_TO_SEC(TIMEDIFF(NOW(), CONVERT_TZ(LastUpdated, 'UTC', 'Europe/Amsterdam'))) < 1800) 
GROUP BY SensorName;