0

Hey guys i show in my page in a table the date of birth from 209 employers.

So i have the next code:

<table id="tabla1" style="border: 1px #000000 solid;" width="%100" cellspacing="2" cellpadding="2" align="center">

<tbody>
<tr>
<td class="tdcolor" align="left"><b>Data_naixement</b></td>
</tr>

<?php
if($rows){
while($post = mysqli_fetch_assoc($result)) {

<tr > 
<td style="font-family: arial;padding-left: 20px;"><?php echo $post["Data_Naixement"]; ?></td>
</tr>
}
}else{
echo "not found";
}
?>

</tbody>
</table>

My code show the date in format YYYY/mm/dd but i want in dd/mm/YYYY How can i do this format?

So i was testing the next code but doestn work good because print only the same date for all employers.

echo $post  ["Data_Naixement"] =$tiempo;
 $date = new DateTime($tiempo);

<td style="font-family: arial;padding-left: 20px;"><?php echo $date->format('d-m-Y'); ?></td>
Shadow
  • 33,525
  • 10
  • 51
  • 64
kestrelol
  • 91
  • 2
  • 6

1 Answers1

0

Use the date() and strtotime() functions:

$ddMMYYYY = date('d/m/Y', strtotime($post["Data_Naixement"]));
user2342558
  • 5,567
  • 5
  • 33
  • 54