0
I gave a search and found no solution to the problem, I really think it should be something simple that maybe I’m wrong.
In the system users can insert some files via intranet, when they insert the file they inform the time that this file will become available, this date is saved as int basically when the guy clicks send in the code happens the following: strtotime(date('d/m/Y H:i:s'))
that picks up the current date, so far all ok.
I believe that the strotime
is not converting the date to a int
which corresponds to the current date.
Then I need to recover this data on a given page to check if it is still available, the date comes in format int
and I convert to a human date more precisely set with date_default_timezone_set('America/Sao_Paulo');
this line gets in the configuration file that is called in all system files.
Then when I get the dates everything responds normally, but when I get the current date again, it replaces the month by the day, even with the formatted date:
$dataatual = strtotime(date('d/m/Y H:i:s'));
echo $comparador1 = date('d/m/Y H:i:s',$dataatual);
The result that comes is03/12/2019 10:36:32
.
The rest of the code works normally, the error is on the line I get the current date that is in code here above, I’m not understanding what is happening.
Then I take the date that comes from the bank also as int and the conversion occurs normally.
- time corresponds to the int coming from the database
- tempoV corresponds to a variable that comes with a value to make change in date ex:
+1 hour
$datacriado = strtotime(date('d/m/Y H:i:s', $x['tempo'])); echo '< br>'; echo $comparador2 = date('d/m/Y H:i:s',$datacriado); $comparador2 = strtotime(date('d/m/Y H:i:s',$datacriado).$x['tempoV']);
I believe it is because you are doing the date(’d/m/Y H:i:s') twice, ai na primeira ele troca o mês por dia ficando em formato correto, 12/03/2019 e na segunda vez que você faz ele inverte denovo ficando 03/12/2019
– Anderson Henrique
In your last code, just do
$datacriado = $x['tempo']
. There’s no reason to turn time into a string and then get the number again...– hkotsubo