-3

Possible Duplicate:
Convert one date format into another in PHP
Convert date format yyyy-mm-dd => dd-mm-yyyy

I want to display the date and time in dd-mm-yyyy hr:min:sec format. Currently it displays as 2012-10-24 16:25:49

The $row['for_dataw'] - is the date and time stored in the mySQL database. What do i do to make it display the way i want it?

print("
<tr><TD>
<A HREF=\"".$_SERVER['PHP_SELF']."?wid=".$row['id']."\">".$this->ptitle."</A></TD>
<TD ALIGN=\"center\">reactions:&nbsp;".$this->react."</TD><TD ALIGN=\"center\"  WIDTH=\"20%\">".$row['for_name']."</TD>
<TD ALIGN=\"center\"  WIDTH=\"20%\">".$row['for_dataw']."
</TD></tr>\n\n");
Community
  • 1
  • 1

2 Answers2

1

Try this:

Here yo create a datetime object and then format the output.

$date = new DateTime($row['for_dataw']);
$date_formated = $date->format('d-m-Y H:i:s');

And now replace $row['for_dataw'] for $date_formated.

  print("<tr><TD><A HREF=\"".$_SERVER['PHP_SELF']."?wid=".$row['id']."\">".$this->ptitle."</A></TD><TD ALIGN=\"center\">reactions:&nbsp;".$this->react."</TD><TD ALIGN=\"center\"  WIDTH=\"20%\">".$row['for_name']."</TD><TD ALIGN=\"center\"  WIDTH=\"20%\">".$date_formated."</TD></tr>\n\n");
slash28cu
  • 1,614
  • 11
  • 23
1
   echo strftime('%d, %m , %D',strtotime($row['for_dataw']));