I have a mySQL table with a date recorded from various different Time Zones. How can I convert the DateTime value to the viewing user TimeZone while doing a SELECT statement in mySQL ?
SELECT ClientID,
convert_tz(MessageDate,???,???)
MeetingType,
MeetingDate,
Comments,
CompanyName
FROM clientCompNotes
WHERE ClID = 970392281 AND CompanyID=411972145
The problem is to accept any timezone from the date recorded in the "MessageDate" field, which looks like this
Wed May 30 2012 12:51:02 GMT-0400 (Eastern Daylight Time)
Many thanks
Dennis
You shouldn't need to do this. MySQL will perform timezone conversion for you, provided that you store your times in
TIMESTAMP
type columns and that you set the sessiontime_zone
variable appropriately. As stated in the manual: