Jump to: navigation, search

Mysql CONVERT TZ

From w3cyberlearnings

Contents

MySQL CONVERT_TZ Function

This function converts from one time zone to another time zone.

Syntax CONVERT_TZ

  • expre: date or datetime expression
  • form: form time zone
  • to: to time zone.
CONVERT_TZ(expre,from, to);

Example 1

mysql> SELECT CONVERT_TZ('2012-01-01 12:00:00', '+00:00','+12:00');
+------------------------------------------------------+
| CONVERT_TZ('2012-01-01 12:00:00', '+00:00','+12:00') |
+------------------------------------------------------+
| 2012-01-02 00:00:00                                  |
+------------------------------------------------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT CONVERT_TZ('2012-01-01 12:00:00', '+00:00','+2:00');
+-----------------------------------------------------+
| CONVERT_TZ('2012-01-01 12:00:00', '+00:00','+2:00') |
+-----------------------------------------------------+
| 2012-01-01 14:00:00                                 |
+-----------------------------------------------------+
1 row in set (0.00 sec)

Related Links



Navigation
Web
SQL
MISC
References