[SOLVED] - Simple Date format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

[SOLVED] - Simple Date format

Post 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.
Last edited by hairyjim on Tue May 25, 2004 7:40 am, edited 1 time in total.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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'";
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post by hairyjim »

Ahhh great. Documentation does not mention the " as modification_date, " bit.

Cheers.
Post Reply