Error saving php mysql time

1

I have a variable to get the current date and time but it is saving with three hours more than the current one, has anyone ever had this problem?

$data = date("d/m/Y H:i:s "); 
    
asked by anonymous 30.06.2014 / 23:59

2 answers

3

Brazil is in GMT-3, probably the system is set to save in GMT + 0. To fix this, you need to demonstrate the structure of your application to know who you are responsible for saving at this time. If you are generating the date through PHP, then certainly the problem is not with MySQL, but with the application. Is the computer time correct?

You can also use the gmdate function, which returns the same format as the date ( ) but uses the local GTM to return the date.

    
01.07.2014 / 00:15
2

Try setting timezone default to be used in the time, example timezone São Paulo :

ini_set('date.timezone', 'America/Sao_Paulo');

or

date_default_timezone_set('America/Sao_Paulo');

View the list of supported timezones

    
01.07.2014 / 00:16