RON_ron Posted August 26, 2010 Share Posted August 26, 2010 I need to change the date format to DD-MM-YYYY. Please help. $SomeVar = $_POST['finco']; $query = "SELECT * FROM news_home WHERE code = '".$SomeVar."' ORDER BY timestamp DESC"; $results = mysql_query($query); $returnS=""; while($line = mysql_fetch_array($results)) { $returnS.= $line["subject"].",,".$line["timestamp"].",,".$line["News"].",,".$line["links"].",,,"; } echo $returnS; mysql_close($link); ?> Link to comment https://forums.phpfreaks.com/topic/211768-change-the-date-format/ Share on other sites More sharing options...
freelance84 Posted August 26, 2010 Share Posted August 26, 2010 http://php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/211768-change-the-date-format/#findComment-1103874 Share on other sites More sharing options...
RON_ron Posted August 26, 2010 Author Share Posted August 26, 2010 I believe this is the way to achieve it but it doesn't seem to work! Any idea why is that? $SomeVar = $_POST['finco']; $query = "SELECT DATE_FORMAT(timestamp, '%d/%m/%Y') FROM news_home WHERE code = '".$SomeVar."' ORDER BY timestamp DESC"; $results = mysql_query($query); $returnS=""; while($line = mysql_fetch_array($results)) { $returnS.= $line["subject"].",,".$line["timestamp"].",,".$line["News"].",,".$line["links"].",,,"; } echo $returnS; mysql_close($link); ?> Link to comment https://forums.phpfreaks.com/topic/211768-change-the-date-format/#findComment-1103881 Share on other sites More sharing options...
Jurge Posted August 26, 2010 Share Posted August 26, 2010 $date = date('D d Y h:i'); Link to comment https://forums.phpfreaks.com/topic/211768-change-the-date-format/#findComment-1103890 Share on other sites More sharing options...
RON_ron Posted August 27, 2010 Author Share Posted August 27, 2010 Worked! Thanks mate!! Link to comment https://forums.phpfreaks.com/topic/211768-change-the-date-format/#findComment-1104260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.