Carlos if I understood your question is this answer that will meet your need, before anything else would be ideal you give a read on documentation and understand the functioning of timezone
and of datetime
of php
.
In your system you should receive the variable and arrow it with the desired Timezone, in your case São Paulo.
new DateTimeZone('America/Sao_Paulo');
Receive the variable per parameter and set the same with this Timezone
$date = new DateTime('2017-10-14 10:04:59 GMT'); //entre os ( ) irá sua variável
$date->setTimezone($tz);
ready his variable was set with the timezone
desired, and at that moment you can use it to save in the bank, but it is important to read the documentation because at this time you implement it in several ways, I did two ways just to exemplify your case, but in the documentation you will understand the various ways of doing.
echo $date->format('Y-m-d g:i:s A');
Upshot: 2017-10-14 7:04:59 am
echo $date->format('l F j Y g:i:s A');
Upshot: Saturday October 14 2017 7:04:59 AM
The whole code goes like this:
$tz = new DateTimeZone('America/Sao_Paulo');
$date = new DateTime('2017-10-14 10:04:59 GMT'); // aqui dentro dos parenteses você deve coloca a sua váriavel DateTime($variavel);
$date->setTimezone($tz); //seta o timezone da váriavel
echo $date->format('Y-m-d g:i:s A'); //imprime o horário no padrão do timezone
echo '<br>';
echo $date->format('l F j Y g:i:s A');
And you can test on this LINK
Does this look like a common bug in hosting, you’re using localhost, or some paid server? the @Wictorchaves response is correct, but you need to know which php settings can be edited if you are a paid server and if this is the case they may already have a
wiki
to this end.– WMomesso
is not an error, I use a dedicated, I think I was unclear, I use an api to receive external information, profiles statistics, to access api I am obliged to use UTC which is the server schedule that provides access to api, my server and website on the other hand, are br, I would have to convert the result that the api sends me to the Brazilian time zone as well
– Wladi Veras
The
timestamp
that you mention in the question refers to a bank table that saves the time for each new interaction usingcurrent timestamp
? or is a variablephp
which takes the current time and saves in the database?– WMomesso
a variable that takes current value from another server.
– Wladi Veras