In general, you need to change the date in the database, from UNIX to normal.

Try so

Дата в колонке date: 1477903122 UPDATE `order` SET `date` = FROM_UNIXTIME(date) where `id` = 698; 

I am updated record on the date: 2016-10-31 10 : 38: 42

And if through php I deduce the date, then it displays: 2016-10-31 11 : 38: 42

Servers are on the same car, pkhp and apache.

 select current_timestamp();// Выводит: 2016-10-31 11:38:52 

I would like that in sql would change to the date as in php, because it writes correct in php ...

  • one
    Smoke hours for summer time? - Venta

1 answer 1

MySQL has a configuration parameter, default-time-zone , which contains the default time zone. You can change it in the MySQL config or install commands

 SET GLOBAL time_zone = timezone; SET time_zone = timezone; 

The first command sets the time zone for the entire MySQL server and requires SUPER privilege. The second command sets the time zone for the current connection. You can view their values ​​with the command

 SELECT @@global.time_zone, @@session.time_zone; 

PHP has a date.timezone configuration parameter. You can change it either in the PHP config, or set the date_default_timezone_set function for the current script. View the current value of the date_default_timezone_get function

The time zones defined in MySQL and PHP Must match.

By the way - a quote from the PHP documentation

Starting with PHP version 5.1.0 (when date / time functions were rewritten), calling any date date function generates E_NOTICE if the time zone has the wrong value, and / or E_WARNING if system parameters or the TZ environment variable are used.