Hi there,
Can anyone tell me how I convert the SYSDATE() format 2008-06-04 21:10:01
into something more viewable like:
04/06/2008 21:10:01
in php?
I am requesting this from the DB in a loop but I need to view "$row["logged"] " as 04/06/2008 21:10:01
<?
$result = mysql_query("SELECT topic, logged FROM forum order by logged desc");
if (!$result) {
echo("<P>Error performing query: " . mysql_error() . "</P>");
exit();
}
while ( $row = mysql_fetch_array($result) ) {
echo("<tr><td> </td><td>" . $row["topic"] . "</td><td>" . $row["logged"] . "</td></tr>");
}
?>
Convert SYSDATE() into something more viewable
Moderator: General Moderators
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: Convert SYSDATE() into something more viewable
You can use the php date function (http://www.php.net/date):
Alternatively, you could use some of the SQL date based manipulation stuff to just have the database do your format conversion for you.
Code: Select all
date("m/d/Y H:i:s", strtotime($row["logged"]));