0
How do I change a date that comes from the database as Y-m-d H-i-s (2018-04-24 16:07:17)
in d-m-Y H-i-s (24-04-2018 16:07:17)
in php?
I tried to perform this operation with the date command, but it didn’t work.
0
How do I change a date that comes from the database as Y-m-d H-i-s (2018-04-24 16:07:17)
in d-m-Y H-i-s (24-04-2018 16:07:17)
in php?
I tried to perform this operation with the date command, but it didn’t work.
4
You can use the class DateTime
of PHP
, see;
$date = new DateTime("2018-04-24 16:07:17");
print_r($date->format("d-m-Y H:i:s")); // saída: 24-04-2018 16:07:17
You can use dynamically if you prefer;
$date = (new DateTime("2018-04-24 16:07:17"))->format("d-m-Y H:i:s")
See more about the class DateTime na documentação do PHP
0
Use date
together with the function strtotime()
, thus date('d-m-Y H:i:s', strtotime($dataVindaDoBanco));
Browser other questions tagged php database
You are not signed in. Login or sign up in order to post.
Use
date
together with the functionstrtotime()
, thusdate('d-m-Y H:i:s', strtotime($dataVindaDoBanco));
– Evandro Lacerda
It worked man, thank you!
– Willian Lima
@Evandrolacerda could publish as a response his solution?
– gato
Published as a response!
– Evandro Lacerda