7
I have this page that displays the emails received from the logged in user, along with the respective dates. I’m trying to format the date display by PHP but it’s not working as I expected. I need the PT-BR date to appear in the first line and the hour and minute in the second line, but it is appearing according to the image. Can you help me ? Follows my code:
<? foreach ($resultado as &$rowmensagens) {
$datamensagem = $rowmensagens['dataenvio'];
$datamensagem = date("d/m/Y H:i:s", strtotime($datamensagem));
$horamensagem = date("H:i:s", strtotime($datamensagem));
$arr_msg = explode("/", $datamensagem);
$diamsg = $arr_msg[0];
$mesmsg = $arr_msg[1];
$anomsg = $arr_msg[2];
$arr_hora = explode(":", $horamensagem);
$hora_msg = $arr_hora[0];
$minuto_msg = $arr_hora[1]; ?>
<strong><?=$diamsg?>/<?=$mesmsg?>/<?=$anomsg?></strong>
<strong><?=$hora_msg?>:<?=$minuto_msg?></strong>
NOTE: This formatting already worked on another occasion and I just copied the structure to this page. Thank you !
Have you tried:
date("d/m/Y", strtotime($datamensagem));
instead ofdate("d/m/Y H:i:s", strtotime($datamensagem));
?– gato
@cat Yes... it removes the time from the first line but in the second line continue to appear all records as 21:00
– goldenleticia
No need to ask the solution question and mark SOLVED the answer with the green check already indicates the solution.
– gato
Read about accepted answer.
– gato