Why do I change the time when I insert?


Hello, I am handling a graph where the date and time are displayed and the parameters are clear, but at the moment of inserting the time and date, the time is advanced by 5 hours.

To insert I take the time and date of the current equipment and insert it in a Timestamp field, and in the database it is correctly captured the time and date it is, but by showing it in the graph it shows me 5 hours more . I leave the sample of the graph and abajito the real HR when inserting in a bd.

asked by Jonathan 19.07.2017 в 23:00

1 answer


It may be the problem with the time zone, try changing it with:


Example working: See Online


$d = new DateTime('now');
echo 'Zona America: ' . $d->format('d-m-Y H:i');

echo PHP_EOL;


$d = new DateTime('now');
echo 'Zona Europa: ' . $d->format('d-m-Y H:i');

// Resultado
// Zona America: 19-07-2017 14:13
// Zona Europa: 19-07-2017 23:13
answered by 19.07.2017 / 23:13