I am doing a job to show the date and time of the insertion in the script in the database, I have to show the date in dd-mm-yyyy format and then the time, how can I do this by the SELECT of the script or by the PHP? If so, how can someone help me with this?
Remarks: I am using PHPMyadmin, the column that is the date is of type datetime. I'm also using PDO stuff.
<?php
try {
$pdo = new PDO('mysql:host=localhost;dbname=agenda', 'root', '');
// define para que o PDO lance exceções caso ocorra erros
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $exc) {
echo "Algum erro foi cometido".$exc->getTraceAsString();
}
$id = $_GET['id'];
$buscasegura= $pdo->prepare("SELECT * FROM pessoa WHERE id = :id");
$vertel = $pdo->prepare("SELECT * FROM 'contatos' WHERE id_pessoa = :id");
$buscasegura->bindValue(":id", $id);
$vertel->bindValue(":id", $id);
$buscasegura->execute();
$vertel->execute();
while($linharesp=$buscasegura->fetch(PDO::FETCH_ASSOC)){
?>
<div class="container body321">
<div class="row">
<h4>Ver informações de : <?php echo $linharesp["nome"];}?> </h4>
<?php
$verregistro = $pdo->prepare('SELECT * FROM 'registro' WHERE id_pessoa = :id');
$verregistro->bindParam(':id',$id);
$verregistro->execute();
?><br>
<h4> Informações de registros</h4>
<div class="col-md-6">
<?php
while($linharesp=$verregistro->fetch(PDO::FETCH_ASSOC)){
$solucao = $linharesp['resolvido'];
if(strcasecmp( $solucao, 'sim' ) == 0){
$class = "alert-success";
}else{
$class = "alert-danger";
}
?>
<div class="info2 <?php echo $class; ?>">
<span class="p">Forma de Comunicação:</span>
<?php echo $linharesp['info']; ?>
<span class="p">Assunto:</span>
<?php echo $linharesp['assunto']; ?>
<span class="p">Descrição:</span>
<?php echo $linharesp['descricao']; ?>
<span class="p">Resolvido?</span>
<?php echo $solucao;?>
</div><br>
<div class="text-right">
<span class="p">Data/Hora:</span>
<?php echo $linharesp['data']; ?>
<a class="label label-danger text-right" href="#">Delete</a>
</div>
<hr>
<?php } ?>
</div>
I'll put a part of my code for you to see.