Jump to content

[SOLVED] Changing Date Format when called from mysql dbase.


Siggles

Recommended Posts

Hi, I have a script that puts a date into a mysql dbase in the 2001-10-01 format. I want it to display in the 01-10-2001 format. My reasoning for using the 'date' type in the dbase is that later on in my website I want to put some dates (for gigs) into date order. That all works fine. However, when outputting the dates using the $row['Date'] it obviously outputs it in the wrong format. I have seen the php functions that change date format but because of the way I output the rows of the mysql dbase I have problems iimplementing them. See below...

 

$result = mysql_query("SELECT * FROM Gigs ORDER BY Date");

while($row = mysql_fetch_array($result))

  {

echo "<table width=\"100%\" >";

echo "<tr >

<td><span class=\"style55\">".$row['Date']."</span></td>

</tr>";

            }

 

Can anyone help. I can explain my script more if it helps.

Remove the ; from the part above, since you aready have it after your </td>

 

 

 

Your advice worked a treat. This is how the script looks for anyone interested. Thak you very much.  :D

 

<span class=\"style55\">".date('d-m-Y',strtotime($row['Date']))."</span>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.