Mysql Date Format Convert

Ads
 

Mysql Date Format Convert

You already Know with the Query to find the current date and time. Now, we help you to convert the Mysql Date Format Conversion into other time zone.

You already Know with the Query to find the current date and time. Now, we help you to convert the Mysql Date Format Conversion into other time zone.

Mysql Date Format Convert

     

You already Know with the Query to find the current date and time. Now, we help you to convert the Mysql Date Format Conversion into other time zone.

Understand with Example

The Tutorial illustrate an example 'Mysql Date Format Convert'. To grasp this concept we use Date now ( ) Query that return you the current today date and time.

now ( ) : The Query now ( ) return you the current date and time

Query for finding current date and time:-

mysql> select now()as date;

Output:-

+---------------------+
| date                |
+---------------------+
| 2008-12-22 10:05:20 |
+---------------------+
1 row in set (0.00 sec)

Query for converting current date and time to other timezone:-

Once you find out with the current date, we can convert the current date and time into other timezone. The below Syntax Query convert the current date and time to other timezone. 

SYNTAX:-CONVERT_TZ(date,from_tz,to_tz)

mysql> select convert_tz('2008-12-22 10:07:00','+05:30','-06:00')as ConvertedDate;

Output:-

+---------------------+
| ConvertedDate       |
+---------------------+
| 2008-12-21 22:37:00 |
+---------------------+
1 row in set (0.00 sec)

Ads

Tutorials   

Ads