PHP - Date_format() Help
iwant this format
dd-mm-yyyy i have a DATETIME var set to DATETIME type in the DB Code: [Select] <?php echo date_format($row['DATETIME'],'%m-%d-%Y') ?> ERROR: Warning: date_format() expects parameter 1 to be DateTime, string given on line 510 Similar TutorialsCan someone tell me what is the fault with my code? SELECT date_format(datecolumn,'%d %M %Y') as date FROM news WHERE article_id=$id $query = "SELECT * FROM my_db ORDER BY timestamp DESC"; $results = mysql_query($query); $returnS=""; while($line = mysql_fetch_array($results)) { $returnS.= $line["subject"].",,".$line["$id"].",,".$line["article"].",,".$line["link"].",,,"; } echo $returnS; mysql_close($link); ?> Hi all, I'm abit stuck, i've got two variables which a $timestamp = $myrow["t_stamp"]; - Grabbed from DB - stored like 2012-04-03 14:02 (for example) $format='F j, Y, g:i a' I'm trying to get it to display like Tuesday, 3rd April 14:02 or something like that but i just cant $timestamp->format($format) is what i've tired working with etc but nothing seems to work as it is only displayed as F j, Y, g:i a as text :S Can anyone help me please. Many thanks! J At which point do I use DATE_FORMAT()? On insert, on select, or ideally can I use it when I echo it out? I haven't used this function before, so I'm not too familliar with it. Can I do something like this?.. echo DATE_FORMAT($item['created_at'], '%d/%m/%Y'); This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308776.0 UPDATE table with topics SET forum = MySQL Help WHERE link = http://www.phpfreaks.com/forums/index.php?topic=347169.0 |