Server with intermittent time [closed]

1

I have an external PHP server that has generated some time problems, sometimes it generates the correct time (eg, it generates 17:00 to 17:00) and sometimes it generates two hours more (eg 19: 00 to 5:00 p.m.).

I have already tried to contact the server support, they say there are no problems, but when writing data with change date I see many of the dates with this problem. I thought about using an external server with a reliable time or some PHP function to handle the error since the server is definitely not reliable ...

    
asked by anonymous 26.12.2016 / 20:20

1 answer

4

Your database is probably one timezone and one server is another.

In MySQL you can configure the time zone by running the following query in the terminal, in some program like the MySQL Workbench, or even by the code.

SET time_zone='America/Sao_Paulo';
-- ou
SET @@global.time_zone = '-3:00';

In PHP Add at the beginning of your code the following:

date_default_timezone_set("America/Sao_Paulo");
    
27.12.2016 / 09:33