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.

Link to comment
Share on other sites

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>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.