0
I have to compare dates to do various functions on the site, what takes the current time is this instruction:
date_default_timezone_set("America/Sao_Paulo");
$hora = date("d/m/Y H:i");
Returning 01/07/2017 18:28
. I have the instruction that reads the database and converts:
$sel_hora_carrossel = $r_sql_car_1[0];
$sel_hora_carrossel_converte = date("d/m/Y H:i", strtotime($sel_hora_carrossel));
Returning 07/01/2017 18:11
and I don’t know why or where else to look, because the dates don’t match, even though they both use the date_default_timezone_set("America/Sao_Paulo");
.
which exactly means, in programming language, they don’t match?
– user60252
Returns do not match. one returns "01/07/2017" and another returns "07/01/2017".
– Rogério Pancini
To confirm, what is the value of
$sel_hora_carrossel
? IS01/07/2017
?– Inkeliz
It seems to me that the date is being recorded in the database in the format
mm/dd/YY
and as 1 is a valid month, it allows you to do the formatting asdd/mm/YY
without error, but generating an unexpected result. You can confirm how you are saved in the database and what query is made to get this value?– Woss
One caution to be taken is with input type="date". Although the dd/mm/yyyy format will be typed in the field, this date will be saved to the seat in the yyyy-mm-dd format ....
– user60252