Jump to content

Recommended Posts

Hello,

 

I have a date set in a database in a field called published like so:

 

2009-01-23 08:00:00

 

and I query the database to get the site out in a set format like so:

 

Friday, 23rd January, 2009

 

$SQL = "SELECT *, DATE_FORMAT(published, '%W, %D %M, %Y') AS formatted_date from blah"
$result = mysql_query($SQL) OR die(mysql_error()); 
$formatted_date = $row['formatted_date'];

 

However, I also want to get the date out in the published field in following format as well:

 

yyyy/mm/dd

 

How can I do this please?

oh sorry I thought you were trying to figure out how to do it lol. wouldn't this work:

 

$SQL = "SELECT *, DATE_FORMAT(published, '%W, %D %M, %Y') AS formatted_date, DATE_FORMAT(published, '%Y/%m/%d') AS another_formatted_date from blah"
$result = mysql_query($SQL) OR die(mysql_error()); 
$formatted_date = $row['formatted_date'];
$another_formatted_date = $row['another_formatted_date'];

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.