Page 1 of 1

[SOLVED] - Simple Date format

Posted: Tue May 25, 2004 7:28 am
by hairyjim
Hi,

I have read through some old posts regarding date formatting from MySQL table and also read a bit of the PHP manual.

I cam up with the follwoing that I thought would work.

//The below is my SQL statement to fetch the data and format the date

Code: Select all

$sql = "SELECT tid, title, bodytext, DATE_FORMAT(modification_date,'%d %m %Y'), counter, product FROM tech_notes WHERE tid = '$id'";
//Then I output the date to the screen. Hopefully in the format I specified above

Code: Select all

echo "<td width="25%">$data&#1111;modification_date]<br>$data&#1111;product]<br>$data&#1111;counter] views</td>";
Unfortunatly I get no output from the $data[modification_date]

Any help is appreciated.

Posted: Tue May 25, 2004 7:32 am
by jason

Code: Select all

$sql = "SELECT tid, title, bodytext, DATE_FORMAT(modification_date,'%d %m %Y'), counter, product FROM tech_notes WHERE tid = '$id'";
Try:

Code: Select all

$sql = "SELECT tid, title, bodytext, DATE_FORMAT(modification_date,'%d %m %Y') as modification_date, counter, product FROM tech_notes WHERE tid = '$id'";

Posted: Tue May 25, 2004 7:40 am
by hairyjim
Ahhh great. Documentation does not mention the " as modification_date, " bit.

Cheers.