How do I set the time zone of MySQL?

后端 未结 20 3662
闹比i
闹比i 2020-11-21 07:07

On one server, when I run:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2009-05-30 16:54:29 |
+---------         


        
20条回答
  •  星月不相逢
    2020-11-21 07:30

    If anyone is using GoDaddy Shared Hosting, you can try for following solution, worked for me.

    When starting DB connection, set the time_zone command in my PDO object e.g.:

    $pdo = new PDO($dsn, $user, $pass, $opt);
    $pdo->exec("SET time_zone='+05:30';");
    

    Where "+05:30" is the TimeZone of India. You can change it as per your need.

    After that; all the MySQL processes related to Date and Time are set with required timezone.

    Source : https://in.godaddy.com/community/cPanel-Hosting/How-to-change-TimeZone-for-MySqL/td-p/31861

提交回复
热议问题