MysQL provides a handy function that takes as arguments the date time value to be converted, the timezone from which it has to be converted and the third argument is the timezone to which the datetime has to be converted. CONVERT_TZ(dt,from_tz,to_tz) CONVERT_TZ() converts a datetime value dt from the time zone given by from_tz to the time zone given by to_tz and returns the resulting value. mysql> SELECT CONVERT_TZ('2008-11-14 12:00:00','+00:00','+10:00'); -> '2008-11-14 22:00:00' mysql> SELECT CONVERT_TZ('2008-11-14 12:00:00','GMT','MET'); -> '2008-11-14 13:00:00' For the latter case, the query will need to access some of the mysql tables.
|
My Blog Title
|