Jump to content

[SOLVED] Format MySQL Date


chordsoflife

Recommended Posts

Thanks for the replies. I've already stored all the data in an array, so I don't want to select anything from the database anymore. Basically, this is where I'm at:

 

$concert['date'] = DATE_FORMAT($concert['date'],'%b %e, %Y');

 

But that doesn't work, of course. Any suggestions?

here's the who shabang (well... not all of it):

 

//select the database I want
mysql_select_db("archive", $connection);


//store the database in an array
$result = mysql_query("SELECT * FROM concerts");


//format the date correctly
$concert['date'] = DATE_FORMAT($concert['date'],'%b %e, %Y');

//spit out one result in this format at a time
while($concert = mysql_fetch_array($result))
  {
  echo "

 

Barand- I'm looking into doing it with PHP too, I'm just not sure how to format it and keep getting errors, but I'm trying to work through it, so I'll learn. Super newbie here with a strong desire to learn.

//select the database I want
mysql_select_db("archive", $connection);


//store the database in an array
$result = mysql_query("SELECT *,DATE_FORMAT(`date`,'%b %e, %Y') as fdate  FROM concerts");

//spit out one result in this format at a time
while($concert = mysql_fetch_array($result))
  {
  echo $concert['fdate'];

or with php...

 

//select the database I want
mysql_select_db("archive", $connection);


//store the database in an array
$result = mysql_query("SELECT * FROM concerts");

//spit out one result in this format at a time
while($concert = mysql_fetch_array($result))
  {
  echo date('M j, Y',strtotime($concert['date']));

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.